diff options
author | Nicolas Pitre <nico@fluxnic.net> | 2010-10-22 16:26:23 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-10-22 14:59:58 -0700 |
commit | 71064a956b25ef519eab340e364d0bc0e786bd11 (patch) | |
tree | ab8c6463b30d9d24b18a64838c4b29d5ad63ec1a /builtin | |
parent | 8a90438506d3b7c8ef8bd802b7ed10c1f12da1d0 (diff) | |
download | git-71064a956b25ef519eab340e364d0bc0e786bd11.tar.gz |
make pack-objects a bit more resilient to repo corruption
Right now, packing valid objects could fail when creating a thin pack
simply because a pack edge object used as a preferred base is corrupted.
Since preferred base objects are not strictly needed to produce a valid
pack, let's not consider the inability to read them as a fatal error.
Delta compression may well be attempted against other objects in the
search window. To avoid warning storms (we are in the inner loop of
the delta search window) a warning is emitted only on the first
occurrence.
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/pack-objects.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index f8eba53c82..3cbeb299d1 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1298,9 +1298,23 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, read_lock(); src->data = read_sha1_file(src_entry->idx.sha1, &type, &sz); read_unlock(); - if (!src->data) + if (!src->data) { + if (src_entry->preferred_base) { + static int warned = 0; + if (!warned++) + warning("object %s cannot be read", + sha1_to_hex(src_entry->idx.sha1)); + /* + * Those objects are not included in the + * resulting pack. Be resilient and ignore + * them if they can't be read, in case the + * pack could be created nevertheless. + */ + return 0; + } die("object %s cannot be read", sha1_to_hex(src_entry->idx.sha1)); + } if (sz != src_size) die("object %s inconsistent object length (%lu vs %lu)", sha1_to_hex(src_entry->idx.sha1), sz, src_size); |