diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-12-04 11:33:07 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-12-04 11:33:08 -0800 |
commit | b50ceab48f46a74571ee2a89048563dd5d3322b9 (patch) | |
tree | 21275fc64df75a448de3b2a00802ec2c2dfc32d9 /sha1_file.c | |
parent | Merge branch 'eg/p4-submit-catch-failure' into maint (diff) | |
parent | gc: remove garbage .idx files from pack dir (diff) | |
download | tgif-b50ceab48f46a74571ee2a89048563dd5d3322b9.tar.xz |
Merge branch 'dk/gc-idx-wo-pack' into maint
Having a leftover .idx file without corresponding .pack file in
the repository hurts performance; "git gc" learned to prune them.
We may want to do the same for .bitmap (and notice but not prune
.keep) without corresponding .pack, but that can be a separate
topic.
* dk/gc-idx-wo-pack:
gc: remove garbage .idx files from pack dir
t5304: test cleaning pack garbage
prepare_packed_git(): refactor garbage reporting in pack directory
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/sha1_file.c b/sha1_file.c index 40a0169ceb..4160e6882d 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1228,27 +1228,16 @@ void install_packed_git(struct packed_git *pack) packed_git = pack; } -void (*report_garbage)(const char *desc, const char *path); +void (*report_garbage)(unsigned seen_bits, const char *path); static void report_helper(const struct string_list *list, int seen_bits, int first, int last) { - const char *msg; - switch (seen_bits) { - case 0: - msg = "no corresponding .idx or .pack"; - break; - case 1: - msg = "no corresponding .idx"; - break; - case 2: - msg = "no corresponding .pack"; - break; - default: + if (seen_bits == (PACKDIR_FILE_PACK|PACKDIR_FILE_IDX)) return; - } + for (; first < last; first++) - report_garbage(msg, list->items[first].string); + report_garbage(seen_bits, list->items[first].string); } static void report_pack_garbage(struct string_list *list) @@ -1271,7 +1260,7 @@ static void report_pack_garbage(struct string_list *list) if (baselen == -1) { const char *dot = strrchr(path, '.'); if (!dot) { - report_garbage("garbage found", path); + report_garbage(PACKDIR_FILE_GARBAGE, path); continue; } baselen = dot - path + 1; @@ -1343,7 +1332,7 @@ static void prepare_packed_git_one(char *objdir, int local) ends_with(de->d_name, ".keep")) string_list_append(&garbage, path.buf); else - report_garbage("garbage found", path.buf); + report_garbage(PACKDIR_FILE_GARBAGE, path.buf); } closedir(dir); report_pack_garbage(&garbage); |