From: Nicolas Pitre <nico@cam.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Pieter de Bie <pdebie@ai.rug.nl>,
"Shawn O. Pearce" <spearce@spearce.org>,
git@vger.kernel.org
Subject: Re: How to replace a single corrupt, packed object?
Date: Sun, 10 Aug 2008 22:55:22 -0400 (EDT) [thread overview]
Message-ID: <alpine.LFD.1.10.0808102146050.22892@xanadu.home> (raw)
In-Reply-To: <alpine.DEB.1.00.0808081841290.24820@pacific.mpi-cbg.de.mpi-cbg.de>
On Fri, 8 Aug 2008, Johannes Schindelin wrote:
> In any case, the pack is too large for me to let my computer repack
> everything, when only one object needs repacking.
By that you mean you cannot/don't want to use repack -f, right?
There _could_ be a way to hack pack-objects so not to reuse bad objects.
However I don't want that to impact the code too much for an
event that hopefully should almost never happens, especially if using -f
does work around it already.
Well, let's see.
[...]
OK, here's what the patch to allow repacking without -f and still using
redundant objects in presence of pack corruption might look like.
Please tell me if that works for you.
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 2dadec1..88e73f3 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -277,6 +277,7 @@ static unsigned long write_object(struct sha1file *f,
*/
if (!to_reuse) {
+ no_reuse:
if (!usable_delta) {
buf = read_sha1_file(entry->idx.sha1, &type, &size);
if (!buf)
@@ -364,14 +365,28 @@ static unsigned long write_object(struct sha1file *f,
reused_delta++;
}
hdrlen = encode_header(type, entry->size, header);
+
offset = entry->in_pack_offset;
revidx = find_pack_revindex(p, offset);
datalen = revidx[1].offset - offset;
if (!pack_to_stdout && p->index_version > 1 &&
- check_pack_crc(p, &w_curs, offset, datalen, revidx->nr))
- die("bad packed object CRC for %s", sha1_to_hex(entry->idx.sha1));
+ check_pack_crc(p, &w_curs, offset, datalen, revidx->nr)) {
+ error("bad packed object CRC for %s", sha1_to_hex(entry->idx.sha1));
+ if (entry->delta)
+ reused_delta--;
+ goto no_reuse;
+ }
+
offset += entry->in_pack_header_size;
datalen -= entry->in_pack_header_size;
+ if (!pack_to_stdout && p->index_version == 1 &&
+ check_pack_inflate(p, &w_curs, offset, datalen, entry->size)) {
+ die("corrupt packed object for %s", sha1_to_hex(entry->idx.sha1));
+ if (entry->delta)
+ reused_delta--;
+ goto no_reuse;
+ }
+
if (type == OBJ_OFS_DELTA) {
off_t ofs = entry->idx.offset - entry->delta->idx.offset;
unsigned pos = sizeof(dheader) - 1;
@@ -394,10 +409,6 @@ static unsigned long write_object(struct sha1file *f,
return 0;
sha1write(f, header, hdrlen);
}
-
- if (!pack_to_stdout && p->index_version == 1 &&
- check_pack_inflate(p, &w_curs, offset, datalen, entry->size))
- die("corrupt packed object for %s", sha1_to_hex(entry->idx.sha1));
copy_pack_data(f, p, &w_curs, offset, datalen);
unuse_pack(&w_curs);
reused++;
Nicolas
next prev parent reply other threads:[~2008-08-11 2:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 14:41 How to replace a single corrupt, packed object? Johannes Schindelin
2008-08-08 14:39 ` Shawn O. Pearce
2008-08-08 14:50 ` Johannes Schindelin
2008-08-08 15:21 ` Johannes Schindelin
2008-08-08 16:23 ` Shawn O. Pearce
2008-08-08 15:30 ` Pieter de Bie
2008-08-08 16:19 ` Shawn O. Pearce
[not found] ` <90E12BC7-1950-41DF-8BE5-C6B63CE060D9@ai.rug.nl>
2008-08-08 16:36 ` Shawn O. Pearce
2008-08-08 16:48 ` Johannes Schindelin
2008-08-11 2:55 ` Nicolas Pitre [this message]
2008-08-11 3:07 ` Shawn O. Pearce
2008-08-11 3:40 ` Nicolas Pitre
2008-08-11 3:46 ` Shawn O. Pearce
2008-08-11 18:59 ` Johannes Schindelin
2008-08-11 1:43 ` Nicolas Pitre
2008-09-15 14:05 ` Johannes Schindelin
2008-09-15 16:26 ` Nicolas Pitre
2008-09-15 16:34 ` Johannes Schindelin
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.1.10.0808102146050.22892@xanadu.home \
--to=nico@cam.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=pdebie@ai.rug.nl \
--cc=spearce@spearce.org \
/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).