Skip to content

Commit 2070950

Browse files
committed
Merge branch 'jk/maint-pack-objects-compete-with-delete'
* jk/maint-pack-objects-compete-with-delete: downgrade "packfile cannot be accessed" errors to warnings pack-objects: protect against disappearing packs
2 parents e75a59a + 58a6a9c commit 2070950

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

builtin/pack-objects.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
804804
off_t offset = find_pack_entry_one(sha1, p);
805805
if (offset) {
806806
if (!found_pack) {
807+
if (!is_pack_valid(p)) {
808+
warning("packfile %s cannot be accessed", p->pack_name);
809+
continue;
810+
}
807811
found_offset = offset;
808812
found_pack = p;
809813
}

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ extern struct packed_git *add_packed_git(const char *, int, int);
10571057
extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t);
10581058
extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t);
10591059
extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
1060+
extern int is_pack_valid(struct packed_git *);
10601061
extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
10611062
extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
10621063
extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);

sha1_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ off_t find_pack_entry_one(const unsigned char *sha1,
19871987
return 0;
19881988
}
19891989

1990-
static int is_pack_valid(struct packed_git *p)
1990+
int is_pack_valid(struct packed_git *p)
19911991
{
19921992
/* An already open pack is known to be valid. */
19931993
if (p->pack_fd != -1)
@@ -2038,7 +2038,7 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
20382038
* was loaded!
20392039
*/
20402040
if (!is_pack_valid(p)) {
2041-
error("packfile %s cannot be accessed", p->pack_name);
2041+
warning("packfile %s cannot be accessed", p->pack_name);
20422042
goto next;
20432043
}
20442044
e->offset = offset;

0 commit comments

Comments
 (0)