🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
2 messages
2 total messages Started by Junio C Hamano Thu, 19 Nov 2026 22:43
Re: [PATCH v5 11/13] builtin/rerere: use `OPT_SUBCOMMAND()`
#3426
Author: Junio C Hamano
Date: Thu, 19 Nov 2026 22:43
99 lines
16035 bytes
Patrick Steinhardt <ps@pks.im> writes:

> 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.

> +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 index

but 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 status

Because 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 -h

Both of which would give you

    usage: git rerere [--[no-]rerere-autoupdate]

        --[no-]rerere-autoupdate
                              register clean resolutions in index

but 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 status

Arguably, 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.
Re: [PATCH v5 11/13] builtin/rerere: use `OPT_SUBCOMMAND()`
#3471
Author: Junio C Hamano
Date: Fri, 20 Nov 2026 16:54
27 lines
13746 bytes
Patrick Steinhardt <ps@pks.im> writes:

> Fair. I think all of this boils down to the pattern of having a default
> subcommand. I think the pattern is okay as long as we really only accept
> `git rerere` without any flags at all. But I think the moment where the
> user wants to do something non-default we should refuse flags and
> instead ask them to use the aliased subcommand, e.g. `git rerere perform
> --rerere-autoupdate`. So essentially:
>
>   usage: git rerere
>      or: git rerere perform [--[no-]rerere-autoupdate
>
> That ship has probably sailed for git-rerere(1) though, and I wouldn't
> feel comfortable breaking that interface now. But at least it's my
> personal takeaway for future commands.

I do not think it is the worst kind of backward-incompatible changes
to give an optional explicit name that you can but do not have to
specify to the default action, so

   usage: git rerere
      or: git rerere [run] [--[no-]rerere-autoupdate

or something (I've always considered the default action to be
"rerere run") would be OK.  I do not know of OPT_SUBCOMMAND()
interface has an optional subcommand bit, though ;-).
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads