Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

discard revindex data when pack list changes

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information...
commit 4b480c6716a7d8e20e7e510827ea81e7939f335a 1 parent a81892d
authored gitster committed
3  builtin-verify-pack.c
... ...
@@ -1,7 +1,7 @@
1 1
 #include "builtin.h"
2 2
 #include "cache.h"
3 3
 #include "pack.h"
4  
-
  4
+#include "pack-revindex.h"
5 5
 
6 6
 #define MAX_CHAIN 50
7 7
 
@@ -129,6 +129,7 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix)
129 129
 		else {
130 130
 			if (verify_one_pack(argv[1], verbose))
131 131
 				err = 1;
  132
+			discard_revindex();
132 133
 			nothing_done = 0;
133 134
 		}
134 135
 		argc--; argv++;
12  pack-revindex.c
@@ -142,3 +142,15 @@ struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)
142 142
 	} while (lo < hi);
143 143
 	die("internal error: pack revindex corrupt");
144 144
 }
  145
+
  146
+void discard_revindex(void)
  147
+{
  148
+	if (pack_revindex_hashsz) {
  149
+		int i;
  150
+		for (i = 0; i < pack_revindex_hashsz; i++)
  151
+			if (pack_revindex[i].revindex)
  152
+				free(pack_revindex[i].revindex);
  153
+		free(pack_revindex);
  154
+		pack_revindex_hashsz = 0;
  155
+	}
  156
+}
1  pack-revindex.h
@@ -7,5 +7,6 @@ struct revindex_entry {
7 7
 };
8 8
 
9 9
 struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs);
  10
+void discard_revindex(void);
10 11
 
11 12
 #endif
1  sha1_file.c
@@ -990,6 +990,7 @@ void prepare_packed_git(void)
990 990
 
991 991
 void reprepare_packed_git(void)
992 992
 {
  993
+	discard_revindex();
993 994
 	prepare_packed_git_run_once = 0;
994 995
 	prepare_packed_git();
995 996
 }
6  t/t5300-pack-object.sh
@@ -187,6 +187,12 @@ test_expect_success \
187 187
 			test-3-${packname_3}.idx'
188 188
 
189 189
 test_expect_success \
  190
+    'verify pack -v' \
  191
+    'git verify-pack -v	test-1-${packname_1}.idx \
  192
+			test-2-${packname_2}.idx \
  193
+			test-3-${packname_3}.idx'
  194
+
  195
+test_expect_success \
190 196
     'verify-pack catches mismatched .idx and .pack files' \
191 197
     'cat test-1-${packname_1}.idx >test-3.idx &&
192 198
      cat test-2-${packname_2}.pack >test-3.pack &&

0 notes on commit 4b480c6

Please sign in to comment.
Something went wrong with that request. Please try again.