Merge branch 'dk/gc-idx-wo-pack' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 4 Dec 2015 19:33:07 +0000 (11:33 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 4 Dec 2015 19:33:08 +0000 (11:33 -0800)
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

1  2 
builtin/gc.c
cache.h
path.c
sha1_file.c
diff --cc builtin/gc.c
index cb13ab72c3cce47ac0b91f2ae7c0f03395ba5b46,203265db76bc49bb190b677cd095fd03a2c86063..42258fe3481dea642e85d8eb97ff175725420121
@@@ -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