Re: [PATCH v3 09/16] repack-midx: factor out `repack_prepare_midx_command()`
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- May 13, 2026, 21:45 UTC
- Message-ID
- <agTw579yuy4iHoMq@szeder.dev>
- In-Reply-To
- <1bd2f194c6f7f64f2ff1e7b55a3a69defcb6a344.1777507303.git.me@ttaylorr.com>
On Wed, Apr 29, 2026 at 08:13:31PM -0400, Taylor Blau wrote:
Show 11 quoted lines
> The `write_midx_included_packs()` function assembles and executes a > `git multi-pack-index write` command, constructing the argument list > inline. > > Future commits will introduce additional callers that need to construct > similar `git multi-pack-index` commands (for both `write` and `compact` > subcommands), so extract the common portions of the command setup into a > reusable `repack_prepare_midx_command()` helper. > > The extracted helper sets `git_cmd`, pushes the `multi-pack-index` > subcommand and verb,
We don't have "verbs" in Git, "multi-pack-index" is the name of the git command, and "write"/"compact"/etc. are the subcommands.
Show 63 quoted lines
> and handles `--progress`/`--no-progress` and
> `--bitmap` flags. The remaining arguments that are specific to the
> `write` subcommand (such as `--stdin-packs`) are left to the caller.
>
> No functional changes are included in this patch.
>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
> repack-midx.c | 30 +++++++++++++++++++-----------
> 1 file changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/repack-midx.c b/repack-midx.c
> index 0682b80c427..83151d4734a 100644
> --- a/repack-midx.c
> +++ b/repack-midx.c
> @@ -275,6 +275,23 @@ static void remove_redundant_bitmaps(struct string_list *include,
> strbuf_release(&path);
> }
>
> +static void repack_prepare_midx_command(struct child_process *cmd,
> + struct repack_write_midx_opts *opts,
> + const char *verb)
> +{
> + cmd->git_cmd = 1;
> +
> + strvec_pushl(&cmd->args, "multi-pack-index", verb, NULL);
> +
> + if (opts->show_progress)
> + strvec_push(&cmd->args, "--progress");
> + else
> + strvec_push(&cmd->args, "--no-progress");
> +
> + if (opts->write_bitmaps)
> + strvec_push(&cmd->args, "--bitmap");
> +}
> +
> int write_midx_included_packs(struct repack_write_midx_opts *opts)
> {
> struct child_process cmd = CHILD_PROCESS_INIT;
> @@ -289,18 +306,9 @@ int write_midx_included_packs(struct repack_write_midx_opts *opts)
> goto done;
>
> cmd.in = -1;
> - cmd.git_cmd = 1;
>
> - strvec_push(&cmd.args, "multi-pack-index");
> - strvec_pushl(&cmd.args, "write", "--stdin-packs", NULL);
> -
> - if (opts->show_progress)
> - strvec_push(&cmd.args, "--progress");
> - else
> - strvec_push(&cmd.args, "--no-progress");
> -
> - if (opts->write_bitmaps)
> - strvec_push(&cmd.args, "--bitmap");
> + repack_prepare_midx_command(&cmd, opts, "write");
> + strvec_push(&cmd.args, "--stdin-packs");
>
> if (preferred)
> strvec_pushf(&cmd.args, "--preferred-pack=%s",
> --
> 2.54.0.16.g1c05dfce579
>