Skip to content

Commit 4bbfb00

Browse files
ttaylorrgitster
authored andcommitted
builtin/repack.c: extract has_existing_non_kept_packs()
When there is: - at least one pre-existing packfile (which is not marked as kept), - repacking with the `-d` flag, and - not doing a cruft repack , then we pass a handful of additional options to the inner `pack-objects` process, like `--unpack-unreachable`, `--keep-unreachable`, and `--pack-loose-unreachable`, in addition to marking any packs we just wrote for promisor remotes as kept in-core (with `--keep-pack`, as opposed to the presence of a ".keep" file on disk). Because we store both cruft and non-cruft packs together in the same `existing.non_kept_packs` list, it suffices to check its `nr` member to see if it is zero or not. But a following change will store cruft- and non-cruft packs separately, meaning this check would break as a result. Prepare for this by extracting this part of the check into a new helper function called `has_existing_non_kept_packs()`. This patch does not introduce any functional changes, but prepares us to make a more isolated change in a subsequent patch. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f2d3bf1 commit 4bbfb00

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

builtin/repack.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ struct existing_packs {
105105
.non_kept_packs = STRING_LIST_INIT_DUP, \
106106
}
107107

108+
static int has_existing_non_kept_packs(const struct existing_packs *existing)
109+
{
110+
return existing->non_kept_packs.nr;
111+
}
112+
108113
static void mark_packs_for_deletion_1(struct string_list *names,
109114
struct string_list *list)
110115
{
@@ -1048,7 +1053,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
10481053
if (pack_everything & ALL_INTO_ONE) {
10491054
repack_promisor_objects(&po_args, &names);
10501055

1051-
if (existing.non_kept_packs.nr && delete_redundant &&
1056+
if (has_existing_non_kept_packs(&existing) &&
1057+
delete_redundant &&
10521058
!(pack_everything & PACK_CRUFT)) {
10531059
for_each_string_list_item(item, &names) {
10541060
strvec_pushf(&cmd.args, "--keep-pack=%s-%s.pack",

0 commit comments

Comments
 (0)