Re: [PATCH v5 11/13] builtin/rerere: use `OPT_SUBCOMMAND()`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 19, 2026, 22:43 UTC
- Message-ID
- <xmqqwlq8tpbm.fsf@gitster.g>
- In-Reply-To
- <20261119-pks-rerere-subcommands-v5-11-0c1092b88958@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 10 quoted lines
> In git-rerere(1) we have our own custom logic to parse subcommands. In > preceding commits we have refactored all of those subcommands so that > they are ready to be used as `OPT_SUBCOMMAND()`s. Switch over to use > these so that we get rid of our custom subcommand parsing. > > Unfortunately this means that we have a backwards-incompatible change > because we no longer accept the "--[no-]rerere-autoupdate" flag for all > subcommands. But this was arguably broken and misleading as we ignore > this flag for any other subcommand aynway. So we cheat a bit and simply > call it a bug that those flags were accepted in the first place.
Aynway.
Show 12 quoted lines
> +static int cmd_rerere_perform(int argc,
> + const char **argv,
> + const char *prefix,
> + struct repository *repo)
> +{
> + int autoupdate = -1;
> + struct option options[] = {
> + OPT_SET_INT(0, "rerere-autoupdate", &autoupdate,
> + N_("register clean resolutions in index"), 1),
> + OPT_END(),
> + };
> + enum rerere_flags flags = 0;The "register clean resolutions in index" text used to be given for "-h"
$ rungit master rerere -h
usage: git rerere [clear | forget <pathspec>... | diff | status | remaining | gc] --[no-]rerere-autoupdate
register clean resolutions in indexbut we moved it to this subcommand.
It was a bug that "git rerere diff --no-rerere-autoupdate" did not complain. Because this option only appears here, those subcommands would now complain when they see the --no-rerere-autoupdate option.
Which is very good.
What is a bit sad is that it has become very hard to actually see this help text.
$ rungit seen rerere -h
usage: git rerere [--[no-]rerere-autoupdate]
or: git rerere clear
or: git rerere diff
or: git rerere forget <pathspec>...
or: git rerere gc
or: git rerere remaining
or: git rerere statusBecause the primary subcommand (i.e., record and replay after you got a conflict in the working tree) does not have a subcommand verb, "git rerere -h" would trigger the help for the top-level command, and the help is shown from there without using the options[] array in this subcommand.
I said "very hard", not impossible, because there is an awkward way to see this.
$ rungit seen rerere -- -h
$ rungit seen rerere --rerere-autoupdate -hBoth of which would give you
usage: git rerere [--[no-]rerere-autoupdate]
--[no-]rerere-autoupdate
register clean resolutions in indexbut it probably is not what users will ever use.
I think it is OK to stop here and leave the above as-is. The only people who use this option are those who already know and are used to it. Everybody else I would imagine would rather use
git -c rerere.autoupdate=no rerere
instead.
It might have fallouts on --git-completion-helper, too.
$ rungit master rerere --git-completion-helper
--rerere-autoupdate --no-rerere-autoupdate
$ rungit seen rerere --git-completion-helper
clear diff forget gc remaining statusArguably, the updated choices are better, but I do not know offhand how the bash completion script uses this (specifically, the old output was so bad that it may have workaround that we will no longer need with your improvements).
Thanks.