From: Patrick Steinhardt <ps@pks.im>
To: Justin Tobler <jltobler@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/5] builtin/multi-pack-index: drop top-level options
Date: Tue, 1 Dec 2026 11:58:24 +0100 [thread overview]
Message-ID: <aw6oUL0h_zEMtCy8@pks.im> (raw)
In-Reply-To: <cc2876d6803f4ac5d504ce18a5380949b97e65cf.1796075503.git.jltobler@gmail.com>
On Mon, Nov 30, 2026 at 03:54:59PM -0600, Justin Tobler wrote:
> When invoking git-multi-pack-index(1), the "--object-dir=" and
> "--[no-]progress" options can be given either before or after the
> subcommand. This calling convention is atypical for Git commands, and it
> requires the options parsed by `cmd_multi_pack_index()` to be stored in
> global state so that they can be accessed by the subcommands. Neither
> option needs to be accepted before the subcommand though.
Ah, this essentially does the same change that I'm also doing for
git-rerere(1) in an in-flight patch series. I'm obviously in favor of
such changes -- they break backwards compatibility, but if you ask me
it's a sensible change to make us more consistent.
> The "--[no-]progress" option was already removed from the top-level
> builtin in 0394f8d002 (builtin/multi-pack-index.c: disable top-level
> --[no-]progress, 2021-09-20). When given before the subcommand, the
> option is not always respected, as each subcommand overrides it
> depending on whether stderr is connected to a terminal. Furthermore, a
> subcommand without a notion of progress would have to ignore the option
> altogether. The option was inadvertently reintroduced by 6b8fb17490
> (builtin/multi-pack-index.c: make '--progress' a common option,
> 2026-02-24), which moved it into the common options that are also parsed
> by `cmd_multi_pack_index()`. Consequently, "git multi-pack-index
> --no-progress write" still shows progress when stderr is connected to a
> terminal.
Heh, fun.
> diff --git a/Documentation/git-multi-pack-index.adoc b/Documentation/git-multi-pack-index.adoc
> index c6d23aeeb9a0..0dd675f3fd46 100644
> --- a/Documentation/git-multi-pack-index.adoc
> +++ b/Documentation/git-multi-pack-index.adoc
> @@ -9,16 +9,16 @@ git-multi-pack-index - Write and verify multi-pack-indexes
> SYNOPSIS
> --------
> [verse]
> -'git multi-pack-index' [<options>] write [--preferred-pack=<pack>]
> +'git multi-pack-index' write [<options>] [--preferred-pack=<pack>]
Is the `[<options>]` placeholder even required now? We already list all
the options, don't we?
> diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
> index 8528f4f513ef..2b4e2f0cce9e 100644
> --- a/builtin/multi-pack-index.c
> +++ b/builtin/multi-pack-index.c
> @@ -415,7 +415,7 @@ int cmd_multi_pack_index(int argc,
> {
> int res;
> parse_opt_subcommand_fn *fn = NULL;
> - struct option builtin_multi_pack_index_options[] = {
> + struct option options[] = {
> OPT_SUBCOMMAND("repack", &fn, cmd_multi_pack_index_repack),
> OPT_SUBCOMMAND("write", &fn, cmd_multi_pack_index_write),
> OPT_SUBCOMMAND("compact", &fn, cmd_multi_pack_index_compact),
> @@ -423,7 +423,6 @@ int cmd_multi_pack_index(int argc,
> OPT_SUBCOMMAND("expire", &fn, cmd_multi_pack_index_expire),
> OPT_END(),
> };
> - struct option *options = parse_options_concat(builtin_multi_pack_index_options, common_opts);
>
> disable_replace_refs();
>
> @@ -431,7 +430,6 @@ int cmd_multi_pack_index(int argc,
>
> argc = parse_options(argc, argv, prefix, options,
> builtin_multi_pack_index_usage, 0);
> - FREE_AND_NULL(options);
>
> res = fn(argc, argv, prefix, repo);
>
I really dislike this `parse_options_concat()` pattern. We can also
easily replace it by defininging something like:
#define MULTI_PACK_INDEX_COMMON_OPTIONS(var) \
OPT_FOO(...), \
OPT_BAR(...)
And then you simply add it to the options at compile time. So maybe
that's another refactoring we could add in a subsequent patch?
... Ah, you already do in your next patch. Great!
Patrick
next prev parent reply other threads:[~2026-12-01 10:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 21:54 [PATCH 0/5] builtin/multi-pack-index: remove global state Justin Tobler
2026-11-30 21:54 ` [PATCH 1/5] builtin/multi-pack-index: resolve default object directory lazily Justin Tobler
2026-12-01 10:58 ` Patrick Steinhardt
2026-12-01 16:39 ` Justin Tobler
2026-11-30 21:54 ` [PATCH 2/5] builtin/multi-pack-index: get rid of `the_repository` Justin Tobler
2026-12-01 10:58 ` Patrick Steinhardt
2026-12-01 16:46 ` Justin Tobler
2026-11-30 21:54 ` [PATCH 3/5] builtin/multi-pack-index: drop top-level options Justin Tobler
2026-12-01 10:58 ` Patrick Steinhardt [this message]
2026-12-01 17:11 ` Justin Tobler
2026-11-30 21:55 ` [PATCH 4/5] builtin/multi-pack-index: simplify how common options are wired up Justin Tobler
2026-12-01 10:58 ` Patrick Steinhardt
2026-12-01 17:13 ` Justin Tobler
2026-11-30 21:55 ` [PATCH 5/5] builtin/multi-pack-index: de-globalize options handling Justin Tobler
2026-12-01 10:59 ` Patrick Steinhardt
2026-12-01 17:18 ` Justin Tobler
2026-12-01 18:16 ` [PATCH v2 0/5] builtin/multi-pack-index: remove global state Justin Tobler
2026-12-01 18:16 ` [PATCH v2 1/5] builtin/multi-pack-index: resolve default object directory lazily Justin Tobler
2026-12-01 18:16 ` [PATCH v2 2/5] builtin/multi-pack-index: get rid of `the_repository` Justin Tobler
2026-12-01 18:16 ` [PATCH v2 3/5] builtin/multi-pack-index: drop top-level options Justin Tobler
2026-12-01 18:16 ` [PATCH v2 4/5] builtin/multi-pack-index: simplify how common options are wired up Justin Tobler
2026-12-01 18:16 ` [PATCH v2 5/5] builtin/multi-pack-index: de-globalize options handling Justin Tobler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aw6oUL0h_zEMtCy8@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox