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 | 908a6e4156dff47d4877478383fd4b79592010e2 (diff) | |
parent | 478f34d2b6ea13d5f56ecec04de7ca7ce18367c0 (diff) | |
download | git-b50ceab48f46a74571ee2a89048563dd5d3322b9.tar.gz git-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 40a0169ce..4160e6882 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); |