Merge branch 'dk/gc-idx-wo-pack'
authorJeff King <peff@peff.net>
Fri, 20 Nov 2015 11:55:34 +0000 (06:55 -0500)
committerJeff King <peff@peff.net>
Fri, 20 Nov 2015 11:55:34 +0000 (06:55 -0500)
Having a leftover .idx file without corresponding .pack file in
the repository hurts performance; "git gc" learned to prune them.

* 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

1  2 
builtin/gc.c
cache.h
path.c
sha1_file.c

diff --cc 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))
diff --cc cache.h
Simple merge
diff --cc path.c
Simple merge
diff --cc sha1_file.c
Simple merge