Skip to content

Commit

Permalink
Merge branch 'np/verify-pack' into maint
Browse files Browse the repository at this point in the history
* np/verify-pack:
  discard revindex data when pack list changes
  • Loading branch information
Junio C Hamano committed Aug 30, 2008
2 parents 53d1589 + 4b480c6 commit d2b9dff
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin-verify-pack.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "builtin.h"
#include "cache.h"
#include "pack.h"

#include "pack-revindex.h"

#define MAX_CHAIN 50

Expand Down Expand Up @@ -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++;
Expand Down
12 changes: 12 additions & 0 deletions pack-revindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions pack-revindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 6 additions & 0 deletions t/t5300-pack-object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ test_expect_success \
test-2-${packname_2}.idx \
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 &&
Expand Down

0 comments on commit d2b9dff

Please sign in to comment.