summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2008-08-27 16:39:46 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-08-27 16:39:46 -0700
commit5a1e8707a6d9c7016a59d9987c1bc72ffe1252c8 (patch)
treef2f8e30270d8231bd7591295e4ce2e9ecf7d0453
parentMerge branch 'da/submodule-sync' (diff)
parentdiscard revindex data when pack list changes (diff)
downloadtgif-5a1e8707a6d9c7016a59d9987c1bc72ffe1252c8.tar.xz
Merge branch 'np/verify-pack'
* np/verify-pack: discard revindex data when pack list changes
-rw-r--r--builtin-verify-pack.c3
-rw-r--r--pack-revindex.c12
-rw-r--r--pack-revindex.h1
-rw-r--r--sha1_file.c1
-rwxr-xr-xt/t5300-pack-object.sh6
5 files changed, 22 insertions, 1 deletions
diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c
index f4ac595695..25a29f11a4 100644
--- a/builtin-verify-pack.c
+++ b/builtin-verify-pack.c
@@ -1,7 +1,7 @@
#include "builtin.h"
#include "cache.h"
#include "pack.h"
-
+#include "pack-revindex.h"
#define MAX_CHAIN 50
@@ -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 cd300bdff5..6096b6224a 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 36a514a6cf..8d5027ad91 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 2aff59b90f..9ee1ed16ad 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();
}
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 645583f9d7..83abe5f25e 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -187,6 +187,12 @@ test_expect_success \
test-3-${packname_3}.idx'
test_expect_success \
+ 'verify pack -v' \
+ 'git verify-pack -v test-1-${packname_1}.idx \
+ test-2-${packname_2}.idx \
+ test-3-${packname_3}.idx'
+
+test_expect_success \
'verify-pack catches mismatched .idx and .pack files' \
'cat test-1-${packname_1}.idx >test-3.idx &&
cat test-2-${packname_2}.pack >test-3.pack &&