Re: [PATCH v2 05/12] builtin/show-ref: refactor `--exclude-existing` options
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Oct 30, 2023, 18:55 UTC
- Message-ID
- <ZT/8GbzAmBq0aRIK@nand.local>
- In-Reply-To
- <bed2a8a07696371e07c0b2d1282ed51c0b1b9fee.1698314128.git.ps@pks.im>
On Thu, Oct 26, 2023 at 11:56:37AM +0200, Patrick Steinhardt wrote:
Show 9 quoted lines
> @@ -95,6 +94,11 @@ static int add_existing(const char *refname,
> return 0;
> }
>
> +struct exclude_existing_options {
> + int enabled;
> + const char *pattern;
> +};
> +Thinking on my earlier suggestion more, I wondered if using the OPT_SUBCOMMAND() function might make things easier to organize and eliminate the need for things like .enabled or having to define structs for each of the sub-commands.
But I don't think that this is (easily) possible to do, since `--exclude-existing` is behind a command-line option, not a separate mode (e.g. "commit-graph verify", not "commit-graph --verify"). So I think you *could* make it work with some combination of OPT_SUBCOMMAND and callbacks to set the function pointer yourself when given the `--exclude-existing` option. But I think that's sufficiently gross as to not be worth it.
Thanks, Taylor