aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2025-10-15 18:29:08 -0400
committerJunio C Hamano <gitster@pobox.com>2025-10-16 10:08:56 -0700
commitf07263fd9fcb6b03f1e1db041269e2d5b85ccff8 (patch)
treeffdf63551b3a4e99e5c7f6632e32a9e58e633b9d
parentbuiltin/repack.c: inline `remove_redundant_bitmaps()` (diff)
downloadgit-f07263fd9fcb6b03f1e1db041269e2d5b85ccff8.tar.gz
git-f07263fd9fcb6b03f1e1db041269e2d5b85ccff8.zip
builtin/repack.c: pass `repack_write_midx_opts` to `midx_included_packs`
Instead of passing individual parameters (in this case, "existing", "names", and "geometry") to `midx_included_packs()`, pass a pointer to a `repack_write_midx_opts` structure instead. Besides reducing the number of parameters necessary to call the `midx_included_packs` function, this refactoring sets us up nicely to inline the call to `midx_included_packs()` into `write_midx_included_packs()`, thus making the caller (in this case, `cmd_repack()`) oblivious to the set of packs being written into the MIDX. In order to do this, `repack_write_midx_opts` has to keep track of the set of existing packs, so add an additional field to point to that set. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/repack.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/builtin/repack.c b/builtin/repack.c
index 271c869268..a518a2b2f3 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -108,6 +108,7 @@ static int repack_config(const char *var, const char *value,
}
struct repack_write_midx_opts {
+ struct existing_packs *existing;
struct string_list *include;
struct pack_geometry *geometry;
struct string_list *names;
@@ -188,10 +189,11 @@ static int midx_has_unknown_packs(struct string_list *include,
}
static void midx_included_packs(struct string_list *include,
- struct existing_packs *existing,
- struct string_list *names,
- struct pack_geometry *geometry)
+ struct repack_write_midx_opts *opts)
{
+ struct existing_packs *existing = opts->existing;
+ struct pack_geometry *geometry = opts->geometry;
+ struct string_list *names = opts->names;
struct string_list_item *item;
struct strbuf buf = STRBUF_INIT;
@@ -242,7 +244,7 @@ static void midx_included_packs(struct string_list *include,
}
}
- if (midx_must_contain_cruft ||
+ if (opts->midx_must_contain_cruft ||
midx_has_unknown_packs(include, geometry, existing)) {
/*
* If there are one or more unknown pack(s) present (see
@@ -994,6 +996,7 @@ int cmd_repack(int argc,
if (write_midx) {
struct string_list include = STRING_LIST_INIT_DUP;
struct repack_write_midx_opts opts = {
+ .existing = &existing,
.include = &include,
.geometry = &geometry,
.names = &names,
@@ -1003,7 +1006,7 @@ int cmd_repack(int argc,
.write_bitmaps = write_bitmaps > 0,
.midx_must_contain_cruft = midx_must_contain_cruft
};
- midx_included_packs(&include, &existing, &names, &geometry);
+ midx_included_packs(&include, &opts);
ret = write_midx_included_packs(&opts);