git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] discard revindex data when pack list changes

From
Nicolas Pitre <nico@cam.org>
Date
Aug 22, 2008, 19:45 UTC
Message-ID
<alpine.LFD.1.10.0808221540290.1624@xanadu.home>
In-Reply-To
<200808221527.21971.johan@herland.net>
This is needed to fix verify-pack -v with multiple pack arguments.

Also, in theory, revindex data (if any) must be discarded whenever reprepare_packed_git() is called. In practice this is hard to trigger though.

Signed-off-by: Nicolas Pitre <nico@cam.org>
---
On Fri, 22 Aug 2008, Johan Herland wrote:
Show 25 quoted lines
> On Friday 22 August 2008, Johan Herland wrote:
> > (I don't have time to look into this right now, but will do so later
> > if nobody comes up with a solution in the meantime...)
> >
> > When running 'git verify-pack -v' on multiple packs (.idx files), it
> > fails for all packs, except the first, with exit code 128, and the
> > following single line:
> >
> > 	fatal: internal error: pack revindex fubar
> >
> > This does not happen when given only a single pack, or when given
> > multiple packs, but without '-v' option.
> >
> > To reproduce, simply do:
> >
> > 	git verify-pack -v .git/objects/pack/*.idx
> >
> > in any repo with more than one pack file.
> >
> > This happens with a fairly current 'next' (1.6.0.96.g2fad1). AFAICS,
> > it also happens in v1.6.0.
> 
> Bisection point to this commit:
> 
> commit 1f5c74f6cf918d317c73b328dcd4cf6f55c44d8a
This patch should fix it.  Lightly tested, but appears to work for me.
I'm leaving for the weekend now so hopefully I've got it right.
diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c
index f4ac595..c88ca18 100644
--- a/builtin-verify-pack.c
+++ b/builtin-verify-pack.c
@@ -129,6 +129,7 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix)
 		else {
 			if (verify_one_pack(argv[1], verbose))
 				err = 1;
+			discard_revindex();
 			nothing_done = 0;
 		}
 		argc--; argv++;
diff --git a/pack-revindex.c b/pack-revindex.c
index cd300bd..6096b62 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -142,3 +142,15 @@ struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)
 	} while (lo < hi);
 	die("internal error: pack revindex corrupt");
 }
+
+void discard_revindex(void)
+{
+	if (pack_revindex_hashsz) {
+		int i;
+		for (i = 0; i < pack_revindex_hashsz; i++)
+			if (pack_revindex[i].revindex)
+				free(pack_revindex[i].revindex);
+		free(pack_revindex);
+		pack_revindex_hashsz = 0;
+	}
+}
diff --git a/pack-revindex.h b/pack-revindex.h
index 36a514a..8d5027a 100644
--- a/pack-revindex.h
+++ b/pack-revindex.h
@@ -7,5 +7,6 @@ struct revindex_entry {
 };
 
 struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs);
+void discard_revindex(void);
 
 #endif
diff --git a/sha1_file.c b/sha1_file.c
index 2aff59b..9ee1ed1 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -990,6 +990,7 @@ void prepare_packed_git(void)
 
 void reprepare_packed_git(void)
 {
+	discard_revindex();
 	prepare_packed_git_run_once = 0;
 	prepare_packed_git();
 }
Previous: Nicolas PitreNext: Johan Herland
Message 5 of 6 in “[BUG?] 'git verify-pack -v' on multiple packs fails for all but the first pack”
  1. Johan HerlandAug 22, 2008
  2. Johan HerlandAug 22, 2008
  3. Selftest for verifying 'git verify-pack -v' with multiple argumentsJohan Herland, Aug 22, 2008
  4. Nicolas PitreAug 22, 2008
  5. discard revindex data when pack list changesNicolas Pitre, Aug 22, 2008
  6. Johan HerlandAug 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.