git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/5] builtin/multi-pack-index: drop top-level options

From
Justin Tobler <jltobler@gmail.com>
Date
Dec 1, 2026, 17:11 UTC
Message-ID
<aw76H8aiByt-UFZp@denethor>
In-Reply-To
<aw6oUL0h_zEMtCy8@pks.im>
On 26/12/01 11:58AM, Patrick Steinhardt wrote:
Show 14 quoted lines
> On Mon, Nov 30, 2026 at 03:54:59PM -0600, Justin Tobler wrote:
> > 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?

Both the synopsis and usage strings still only explicitly list the options specific to each subcommand. The common options are only denoted via `[<options>]`. It might just be better to be explicit here though and write out both the common options for each of the subcommands. I'll do this in the next version.

Show 41 quoted lines
> > 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!
Yup! :)
-Justin
Previous: Patrick SteinhardtNext: Justin Tobler
Message 10 of 25 in “builtin/multi-pack-index: remove global state”
  1. 0/5 builtin/multi-pack-index: remove global stateJustin Tobler, Nov 30, 2026
  2. 1/5 builtin/multi-pack-index: resolve default object directory lazilyJustin Tobler, Nov 30, 2026
  3. Patrick SteinhardtDec 1, 2026
  4. Justin ToblerDec 1, 2026
  5. 2/5 builtin/multi-pack-index: get rid of `the_repository`Justin Tobler, Nov 30, 2026
  6. Patrick SteinhardtDec 1, 2026
  7. Justin ToblerDec 1, 2026
  8. 3/5 builtin/multi-pack-index: drop top-level optionsJustin Tobler, Nov 30, 2026
  9. Patrick SteinhardtDec 1, 2026
  10. Justin ToblerDec 1, 2026
  11. 4/5 builtin/multi-pack-index: simplify how common options are wired upJustin Tobler, Nov 30, 2026
  12. Patrick SteinhardtDec 1, 2026
  13. Justin ToblerDec 1, 2026
  14. 5/5 builtin/multi-pack-index: de-globalize options handlingJustin Tobler, Nov 30, 2026
  15. Patrick SteinhardtDec 1, 2026
  16. Justin ToblerDec 1, 2026
  17. 0/5 builtin/multi-pack-index: remove global stateJustin Tobler, Dec 1, 2026
  18. 1/5 builtin/multi-pack-index: resolve default object directory lazilyJustin Tobler, Dec 1, 2026
  19. Patrick SteinhardtDec 2, 2026
  20. 2/5 builtin/multi-pack-index: get rid of `the_repository`Justin Tobler, Dec 1, 2026
  21. 3/5 builtin/multi-pack-index: drop top-level optionsJustin Tobler, Dec 1, 2026
  22. 4/5 builtin/multi-pack-index: simplify how common options are wired upJustin Tobler, Dec 1, 2026
  23. 5/5 builtin/multi-pack-index: de-globalize options handlingJustin Tobler, Dec 1, 2026
  24. Patrick SteinhardtDec 2, 2026
  25. Patrick SteinhardtDec 2, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.