From: Nicolas Pitre <nico@fluxnic.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] make pack-objects a bit more resilient to repo corruption
Date: Fri, 22 Oct 2010 00:53:32 -0400 (EDT) [thread overview]
Message-ID: <alpine.LFD.2.00.1010220037250.2764@xanadu.home> (raw)
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.
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
---
I wrote this patch while helping Uwe with his repo corruption. While
his problem turned out to be different from the one this patch is
addressing (see previous patch I posted) I think that since I did the
patch already then this wouldn't hurt to have this one merged too.
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index f8eba53..674247e 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1298,9 +1298,19 @@ 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) {
+ /*
+ * 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);
next reply other threads:[~2010-10-22 4:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 4:53 Nicolas Pitre [this message]
2010-10-22 14:46 ` [PATCH] make pack-objects a bit more resilient to repo corruption Jeff King
2010-10-22 15:24 ` Drew Northup
2010-10-22 18:54 ` Nicolas Pitre
2010-10-22 18:42 ` Nicolas Pitre
2010-10-22 20:26 ` [PATCH v2] " Nicolas Pitre
2010-10-22 20:50 ` Sverre Rabbelier
2010-10-22 21:19 ` Nicolas Pitre
2010-10-22 21:59 ` Junio C Hamano
2010-10-24 2:26 ` Geert Bosch
2010-10-24 2:47 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.00.1010220037250.2764@xanadu.home \
--to=nico@fluxnic.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).