Git development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Justin Tobler <jltobler@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/5] builtin/multi-pack-index: simplify how common options are wired up
Date: Tue, 1 Dec 2026 11:58:32 +0100	[thread overview]
Message-ID: <aw6oWC_yENDJjd3h@pks.im> (raw)
In-Reply-To: <1c16a0988239253b3695c68c138b4b71ccc00de9.1796075503.git.jltobler@gmail.com>

On Mon, Nov 30, 2026 at 03:55:00PM -0600, Justin Tobler wrote:
> diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
> index 2b4e2f0cce9e..d3881aee6a11 100644
> --- a/builtin/multi-pack-index.c
> +++ b/builtin/multi-pack-index.c
> @@ -100,20 +100,13 @@ static struct odb_source_packed *handle_object_dir_option(struct repository *rep
>  	return dir->packed;
>  }
>  
> -static struct option common_opts[] = {
> -	OPT_CALLBACK(0, "object-dir", &opts.object_dir,
> -	  N_("directory"),
> -	  N_("object directory containing set of packfile and pack-index pairs"),
> -	  parse_object_dir),
> -	OPT_BIT(0, "progress", &opts.flags, N_("force progress reporting"),
> -		MIDX_PROGRESS),
> -	OPT_END(),
> -};
> -
> -static struct option *add_common_options(struct option *prev)
> -{
> -	return parse_options_concat(common_opts, prev);
> -}
> +#define MULTI_PACK_INDEX_COMMON_OPTIONS(opts) \
> +	OPT_CALLBACK(0, "object-dir", &(opts)->object_dir, \
> +	  N_("directory"), \
> +	  N_("object directory containing set of packfile and pack-index pairs"), \
> +	  parse_object_dir), \
> +	OPT_BIT(0, "progress", &(opts)->flags, N_("force progress reporting"), \
> +		MIDX_PROGRESS)

Awesome, exactly what I was hoping for.

> @@ -154,8 +147,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
>  				      const char *prefix,
>  				      struct repository *repo)
>  {
> -	struct option *options;
> -	static struct option builtin_multi_pack_index_write_options[] = {
> +	static struct option options[] = {
>  		OPT_STRING(0, "preferred-pack", &opts.preferred_pack,
>  			   N_("preferred-pack"),
>  			   N_("pack for reuse when computing a multi-pack bitmap")),
> @@ -172,6 +164,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
>  			 N_("write multi-pack index containing only given indexes")),
>  		OPT_FILENAME(0, "refs-snapshot", &opts.refs_snapshot,
>  			     N_("refs snapshot for selecting bitmap commits")),
> +		MULTI_PACK_INDEX_COMMON_OPTIONS(&opts),
>  		OPT_END(),
>  	};
>  	struct odb_source_packed *packed_source;

I think this causes a slight change in that the common opitons are now
at the end of these options, whereas they have been at the beginning
beforehand. Doesn't really matter much, but it can also easily be
avoided by adding the common options first.

> @@ -380,16 +357,14 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv,
>  				       const char *prefix,
>  				       struct repository *repo)
>  {
> -	struct option *options;
> -	static struct option builtin_multi_pack_index_repack_options[] = {
> +	static struct option options[] = {
>  		OPT_UNSIGNED(0, "batch-size", &opts.batch_size,
>  		  N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")),
> +		MULTI_PACK_INDEX_COMMON_OPTIONS(&opts),
>  		OPT_END(),
>  	};

Likewise.

Patrick

  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
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 [this message]
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=aw6oWC_yENDJjd3h@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