Skip to content

Commit 5605685

Browse files
committed
Merge branch 'np/pack-broken-boundary' into maint
* np/pack-broken-boundary: make pack-objects a bit more resilient to repo corruption
2 parents ded4dfd + 71064a9 commit 5605685

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

builtin/pack-objects.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,9 +1298,23 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
12981298
read_lock();
12991299
src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz);
13001300
read_unlock();
1301-
if (!src->data)
1301+
if (!src->data) {
1302+
if (src_entry->preferred_base) {
1303+
static int warned = 0;
1304+
if (!warned++)
1305+
warning("object %s cannot be read",
1306+
sha1_to_hex(src_entry->idx.sha1));
1307+
/*
1308+
* Those objects are not included in the
1309+
* resulting pack. Be resilient and ignore
1310+
* them if they can't be read, in case the
1311+
* pack could be created nevertheless.
1312+
*/
1313+
return 0;
1314+
}
13021315
die("object %s cannot be read",
13031316
sha1_to_hex(src_entry->idx.sha1));
1317+
}
13041318
if (sz != src_size)
13051319
die("object %s inconsistent object length (%lu vs %lu)",
13061320
sha1_to_hex(src_entry->idx.sha1), sz, src_size);

0 commit comments

Comments
 (0)