From: Junio C Hamano Date: Fri, 4 Dec 2015 19:33:07 +0000 (-0800) Subject: Merge branch 'dk/gc-idx-wo-pack' into maint X-Git-Tag: v2.6.4~8 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b50ceab48f46a74571ee2a89048563dd5d3322b9 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 --- b50ceab48f46a74571ee2a89048563dd5d3322b9 diff --cc builtin/gc.c index cb13ab72c3,203265db76..42258fe348 --- a/builtin/gc.c +++ b/builtin/gc.c @@@ -43,9 -42,37 +43,25 @@@ static struct argv_array prune = ARGV_A static struct argv_array prune_worktrees = ARGV_ARRAY_INIT; static struct argv_array rerere = ARGV_ARRAY_INIT; -static char *pidfile; - -static void remove_pidfile(void) -{ - if (pidfile) - unlink(pidfile); -} - -static void remove_pidfile_on_signal(int signo) -{ - remove_pidfile(); - sigchain_pop(signo); - raise(signo); -} +static struct tempfile pidfile; +static struct lock_file log_lock; + static struct string_list pack_garbage = STRING_LIST_INIT_DUP; + + static void clean_pack_garbage(void) + { + int i; + for (i = 0; i < pack_garbage.nr; i++) + unlink_or_warn(pack_garbage.items[i].string); + string_list_clear(&pack_garbage, 0); + } + + static void report_pack_garbage(unsigned seen_bits, const char *path) + { + if (seen_bits == PACKDIR_FILE_IDX) + string_list_append(&pack_garbage, path); + } + static void git_config_date_string(const char *key, const char **output) { if (git_config_get_string_const(key, output))