Subject: Re: [PATCH v3 2/2] replay: add --revert mode to reverse commit changes

From: Toon Claes <[email-masked]>
Date: Mon, 23 Feb 2026 12:23:55 +0100

Christian Couder <[email-masked]> writes:

> On Fri, Feb 20, 2026 at 6:35 PM Toon Claes <[email-masked]> wrote:
>>
>> The modes `--onto`, `--advance` and `--revert` seem to be extremely
>> different from each other. So I'm starting to wonder whether it won't
>> make more sense to instead create subcommands instead of options for
>> these. Maybe something like:
>>
>>     git replay revert --base=<branch> <revision-range>
>>     git replay pick --base=<branch> <revision-range>
>>     git replay replay --base=<branch> <revision-range>
>
> (I think you mean `git replay rebase` in the above line, no?)

I'm fine either way, but I agree saying "replay" twice looks weird.

> I agree that we should consider this. But I think we should do it
> separately in another series, after this one about --revert is merged.
> We might even consider waiting until we have more experience using
> `git replay --revert` to make a more informed decision. We shouldn't
> wait for too long either though...

I can agree with that.

> Also if we nearly always need a base, then why not:
>
>   git replay rebase <base> <revision-range>
>   git replay pick <base> <revision-range>
>   git replay revert <base> <revision-range>
>
> ?
>
> Or what was the reason for introducing --base=<branch>?

Well, the modes 'revert' and 'pick' work different from 'replay'. The
latter looks in <revision-range> to determine which refs need updating.
This can lead to multiple refs that will be updated (with option
--contained). The first two only operate on one ref and ignore whatever
refs are in <revision-range>. (I think, correct me if I'm wrong)

That's why I suggest to take it one step further:

     git replay revert --ref=<branch> <revision-range>
     git replay pick --ref=<branch> <revision-range>
     git replay rebase --onto=<branch> <revision-range>

That's why the first two use --ref instead of --onto.

As a benefit, this also enables me to address another issue I have:
git-replay(1) cannot be used on bare commit IDs. This issue was also
raised by Yee Cheng Chin[1].

With options `--onto` and `--ref` we can fix this. Because you can use
them together:

    git replay replay --ref=ref/heads/branch --onto=112233 aabbcc..ddeeff
    git replay pick --ref=ref/heads/branch --onto=112233 aabbcc..ddeeff
    git replay rebase --ref=ref/heads/branch --onto=112233 aabbcc..ddeeff

The value of --onto doesn't need to be a ref, but --ref needs. For the
'rebase' subcommand option --ref is optional, for the other two --onto
is optional. And when one of both is omitted, one defaults to the other.

What do you think?

[1]: https://lore.kernel.org/git/[email-masked]/

-- 
Cheers,
Toon