Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-06-26 19:29:49 +0300
committerJunio C Hamano <gitster@pobox.com>2023-06-26 19:29:50 +0300
commite224f26892ffc3e2cb98fd68c6f74dc3d650ffc8 (patch)
tree96c5eda55c9f8f78c26f04c736823734216acfd2 /builtin
parent8d5c5a05d7abd67f8b667c888fe17783e1d676a5 (diff)
parent73320e49add4b56aba9bf5236a216498fa8ccc22 (diff)
Merge branch 'tb/collect-pack-filenames-fix'
Avoid breakage of "git pack-objects --cruft" due to inconsistency between the way the code enumerates packfiles in the repository. * tb/collect-pack-filenames-fix: builtin/repack.c: only collect fully-formed packs
Diffstat (limited to 'builtin')
-rw-r--r--builtin/repack.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/builtin/repack.c b/builtin/repack.c
index 0541c3ce15..1e21a21ea8 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -95,8 +95,8 @@ static int repack_config(const char *var, const char *value, void *cb)
}
/*
- * Adds all packs hex strings to either fname_nonkept_list or
- * fname_kept_list based on whether each pack has a corresponding
+ * Adds all packs hex strings (pack-$HASH) to either fname_nonkept_list
+ * or fname_kept_list based on whether each pack has a corresponding
* .keep file or not. Packs without a .keep file are not to be kept
* if we are going to pack everything into one file.
*/
@@ -107,6 +107,7 @@ static void collect_pack_filenames(struct string_list *fname_nonkept_list,
DIR *dir;
struct dirent *e;
char *fname;
+ struct strbuf buf = STRBUF_INIT;
if (!(dir = opendir(packdir)))
return;
@@ -115,11 +116,15 @@ static void collect_pack_filenames(struct string_list *fname_nonkept_list,
size_t len;
int i;
- if (!strip_suffix(e->d_name, ".pack", &len))
+ if (!strip_suffix(e->d_name, ".idx", &len))
continue;
+ strbuf_reset(&buf);
+ strbuf_add(&buf, e->d_name, len);
+ strbuf_addstr(&buf, ".pack");
+
for (i = 0; i < extra_keep->nr; i++)
- if (!fspathcmp(e->d_name, extra_keep->items[i].string))
+ if (!fspathcmp(buf.buf, extra_keep->items[i].string))
break;
fname = xmemdupz(e->d_name, len);
@@ -136,6 +141,7 @@ static void collect_pack_filenames(struct string_list *fname_nonkept_list,
}
}
closedir(dir);
+ strbuf_release(&buf);
string_list_sort(fname_kept_list);
}