diff options
author | Jeff King <peff@peff.net> | 2015-11-20 06:55:34 -0500 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2015-11-20 06:55:34 -0500 |
commit | 45014beac004a610938a265698605c18ab126087 (patch) | |
tree | 97b7dcfd2a4edf2e0044cb1f498a902aea158441 /builtin/count-objects.c | |
parent | f34be46e47773d03e9d09641209121591a6b37c8 (diff) | |
parent | 478f34d2b6ea13d5f56ecec04de7ca7ce18367c0 (diff) | |
download | git-45014beac004a610938a265698605c18ab126087.tar.gz |
Merge branch 'dk/gc-idx-wo-pack'
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
Diffstat (limited to 'builtin/count-objects.c')
-rw-r--r-- | builtin/count-objects.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/builtin/count-objects.c b/builtin/count-objects.c index ad0c79954a..ba9291944f 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -15,9 +15,31 @@ static int verbose; static unsigned long loose, packed, packed_loose; static off_t loose_size; -static void real_report_garbage(const char *desc, const char *path) +static const char *bits_to_msg(unsigned seen_bits) +{ + switch (seen_bits) { + case 0: + return "no corresponding .idx or .pack"; + case PACKDIR_FILE_GARBAGE: + return "garbage found"; + case PACKDIR_FILE_PACK: + return "no corresponding .idx"; + case PACKDIR_FILE_IDX: + return "no corresponding .pack"; + case PACKDIR_FILE_PACK|PACKDIR_FILE_IDX: + default: + return NULL; + } +} + +static void real_report_garbage(unsigned seen_bits, const char *path) { struct stat st; + const char *desc = bits_to_msg(seen_bits); + + if (!desc) + return; + if (!stat(path, &st)) size_garbage += st.st_size; warning("%s: %s", desc, path); @@ -27,7 +49,7 @@ static void real_report_garbage(const char *desc, const char *path) static void loose_garbage(const char *path) { if (verbose) - report_garbage("garbage found", path); + report_garbage(PACKDIR_FILE_GARBAGE, path); } static int count_loose(const unsigned char *sha1, const char *path, void *data) |