# Interactive rebase: using "pick" for merge commits

10 messages from 2024-02-09 to 2024-02-27. Participants: Stefan Haller, Phillip Wood, Patrick Steinhardt, Junio C Hamano, phillip.wood123@gmail.com.
Thread: https://gitlist.dev/t/60884

## Stefan Haller, 2024-02-09 15:52

Subject: Interactive rebase: using "pick" for merge commits
Message-ID: <424f2e08-a2ad-4bb2-8a6b-136c426dc127@haller-berlin.de>
URL: https://gitlist.dev/e/424f2e08-a2ad-4bb2-8a6b-136c426dc127%40haller-berlin.de

```
When I do an interactive rebase, and manually enter a "pick" with the
commit hash of a merge commit, I get the following confusing error message:

error: commit fa1afe1 is a merge but no -m option was given.
hint: Could not execute the todo command
hint:
hint:     pick fa1afe1 some subject
hint:
hint: It has been rescheduled; [rest of message snipped]

This error message makes it sound like I could somehow add "-m1" after
the "pick" to make it work (which is actually what I would like to be
able to do). I had to go read the source code to find out that that's
not the case, and the error message only comes from the fact that the
code is shared with the cherry-pick and revert commands, which do have
the -m option.

Is it crazy to want pick to work like this? Should it be supported?

-Stefan

```

## Phillip Wood, 2024-02-09 16:24

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <ad561600-faf6-4d3c-80b2-34b3d1a1b99e@gmail.com>
URL: https://gitlist.dev/e/ad561600-faf6-4d3c-80b2-34b3d1a1b99e%40gmail.com
In-Reply-To: <424f2e08-a2ad-4bb2-8a6b-136c426dc127@haller-berlin.de>

```
Hi Stefan

On 09/02/2024 15:52, Stefan Haller wrote:
> When I do an interactive rebase, and manually enter a "pick" with the
> commit hash of a merge commit, I get the following confusing error message:
> 
> error: commit fa1afe1 is a merge but no -m option was given.
> hint: Could not execute the todo command
> hint:
> hint:     pick fa1afe1 some subject
> hint:
> hint: It has been rescheduled; [rest of message snipped]
> 
> This error message makes it sound like I could somehow add "-m1" after
> the "pick" to make it work (which is actually what I would like to be
> able to do). I had to go read the source code to find out that that's
> not the case, and the error message only comes from the fact that the
> code is shared with the cherry-pick and revert commands, which do have
> the -m option.

Oh, that's unfortunate - we should really reject the todo list when we 
parse it at the start of the rebase if it is going to try and "pick" a 
merge.

> Is it crazy to want pick to work like this? Should it be supported?

It causes problems trying to maintain the topology. In the past there 
was a "--preserve-merges" option that allowed one to "pick" merges but 
it broke if the user edited the todo list. The "--rebase-merges" option 
was introduced with the "label", "reset" and "merge" todo list 
instructions to allow the user to control the topology.

Best Wishes

Phillip

```

## Stefan Haller, 2024-02-10 09:23

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <65c65f6b-5ec8-4fa0-a17c-0f2c0d32b390@haller-berlin.de>
URL: https://gitlist.dev/e/65c65f6b-5ec8-4fa0-a17c-0f2c0d32b390%40haller-berlin.de
In-Reply-To: <ad561600-faf6-4d3c-80b2-34b3d1a1b99e@gmail.com>

```
On 09.02.24 17:24, Phillip Wood wrote:
> On 09/02/2024 15:52, Stefan Haller wrote:
>> When I do an interactive rebase, and manually enter a "pick" with the
>> commit hash of a merge commit, I get the following confusing error
>> message:
>>
>> error: commit fa1afe1 is a merge but no -m option was given.
>> 
>> Is it crazy to want pick to work like this? Should it be supported?
> 
> It causes problems trying to maintain the topology. In the past there
> was a "--preserve-merges" option that allowed one to "pick" merges but
> it broke if the user edited the todo list. The "--rebase-merges" option
> was introduced with the "label", "reset" and "merge" todo list
> instructions to allow the user to control the topology.

Yes, I'm familiar with all this, but that's not what I mean. I don't
want to maintain the topology here, and I'm also not suggesting that git
itself generates such "pick" entries with -mX arguments (maybe I wasn't
clear on that). What I want to do is to add such entries myself, as a
user, resulting in the equivalent of doing a "break" at that point in
the rebase and doing a "git cherry-pick -mX <hash-of-merge-commit>"
manually.

-Stefan

```

## Patrick Steinhardt, 2024-02-12 07:15

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <ZcnFl8kypKRYeLo3@tanuki>
URL: https://gitlist.dev/e/ZcnFl8kypKRYeLo3%40tanuki
In-Reply-To: <65c65f6b-5ec8-4fa0-a17c-0f2c0d32b390@haller-berlin.de>

```
On Sat, Feb 10, 2024 at 10:23:16AM +0100, Stefan Haller wrote:
> On 09.02.24 17:24, Phillip Wood wrote:
> > On 09/02/2024 15:52, Stefan Haller wrote:
> >> When I do an interactive rebase, and manually enter a "pick" with the
> >> commit hash of a merge commit, I get the following confusing error
> >> message:
> >>
> >> error: commit fa1afe1 is a merge but no -m option was given.
> >> 
> >> Is it crazy to want pick to work like this? Should it be supported?
> > 
> > It causes problems trying to maintain the topology. In the past there
> > was a "--preserve-merges" option that allowed one to "pick" merges but
> > it broke if the user edited the todo list. The "--rebase-merges" option
> > was introduced with the "label", "reset" and "merge" todo list
> > instructions to allow the user to control the topology.
> 
> Yes, I'm familiar with all this, but that's not what I mean. I don't
> want to maintain the topology here, and I'm also not suggesting that git
> itself generates such "pick" entries with -mX arguments (maybe I wasn't
> clear on that). What I want to do is to add such entries myself, as a
> user, resulting in the equivalent of doing a "break" at that point in
> the rebase and doing a "git cherry-pick -mX <hash-of-merge-commit>"
> manually.

It would be neat indeed if this could be specified in the instruction
sheet. We already support options for the "merge" instruction, so
extending "pick" to support options isn't that far-fetched. Then it
would become possible to say "pick -m1 fa1afe1".

Patrick

```

## Phillip Wood, 2024-02-12 14:38

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <040f142c-7ee2-429e-88eb-d328b01a4b8c@gmail.com>
URL: https://gitlist.dev/e/040f142c-7ee2-429e-88eb-d328b01a4b8c%40gmail.com
In-Reply-To: <ZcnFl8kypKRYeLo3@tanuki>

```
Hi Patrick and Stefan

On 12/02/2024 07:15, Patrick Steinhardt wrote:
> On Sat, Feb 10, 2024 at 10:23:16AM +0100, Stefan Haller wrote:
>> On 09.02.24 17:24, Phillip Wood wrote:
>> Yes, I'm familiar with all this, but that's not what I mean. I don't
>> want to maintain the topology here, and I'm also not suggesting that git
>> itself generates such "pick" entries with -mX arguments (maybe I wasn't
>> clear on that). What I want to do is to add such entries myself, as a
>> user, resulting in the equivalent of doing a "break" at that point in
>> the rebase and doing a "git cherry-pick -mX <hash-of-merge-commit>"
>> manually.
> 
> It would be neat indeed if this could be specified in the instruction
> sheet. We already support options for the "merge" instruction, so
> extending "pick" to support options isn't that far-fetched. Then it
> would become possible to say "pick -m1 fa1afe1".

It would certainly be possible to extend the sequencer to do that but 
I'm not familiar with why people use "git cherry-pick -m" [1] so I'm 
wondering what this would be used for. It would involve a bit of extra 
complexity so I think we'd want a compelling reason as to why 
cherry-picking merges without maintaining the topology is useful 
especially as one can currently do that via "exec git cherry-pick -m ..."

Best Wishes

Phillip

[1] I did a quick web search and the results all seemed to focus on how 
to do it rather than why you'd want to.

```

## Junio C Hamano, 2024-02-12 16:39

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <xmqqcyt18wn3.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqcyt18wn3.fsf%40gitster.g
In-Reply-To: <ZcnFl8kypKRYeLo3@tanuki>

```
Patrick Steinhardt <ps@pks.im> writes:

> On Sat, Feb 10, 2024 at 10:23:16AM +0100, Stefan Haller wrote:
>> On 09.02.24 17:24, Phillip Wood wrote:
>> > On 09/02/2024 15:52, Stefan Haller wrote:
>> >> When I do an interactive rebase, and manually enter a "pick" with the
>> >> commit hash of a merge commit, I get the following confusing error
>> >> message:
>> >>
>> >> error: commit fa1afe1 is a merge but no -m option was given.
>> >> 
>> >> Is it crazy to want pick to work like this? Should it be supported?
>> > 
>> > It causes problems trying to maintain the topology. In the past there
>> > was a "--preserve-merges" option that allowed one to "pick" merges but
>> > it broke if the user edited the todo list. The "--rebase-merges" option
>> > was introduced with the "label", "reset" and "merge" todo list
>> > instructions to allow the user to control the topology.
>> 
>> Yes, I'm familiar with all this, but that's not what I mean. I don't
>> want to maintain the topology here, and I'm also not suggesting that git
>> itself generates such "pick" entries with -mX arguments (maybe I wasn't
>> clear on that). What I want to do is to add such entries myself, as a
>> user, resulting in the equivalent of doing a "break" at that point in
>> the rebase and doing a "git cherry-pick -mX <hash-of-merge-commit>"
>> manually.
>
> It would be neat indeed if this could be specified in the instruction
> sheet. We already support options for the "merge" instruction, so
> extending "pick" to support options isn't that far-fetched. Then it
> would become possible to say "pick -m1 fa1afe1".

Would adding "x git cherry-pick -m 1 $that_one" work there?

```

## Stefan Haller, 2024-02-23 20:59

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <2739325d-93b1-445c-aac9-3e0ec54a27e4@haller-berlin.de>
URL: https://gitlist.dev/e/2739325d-93b1-445c-aac9-3e0ec54a27e4%40haller-berlin.de
In-Reply-To: <040f142c-7ee2-429e-88eb-d328b01a4b8c@gmail.com>

```
On 12.02.24 15:38, Phillip Wood wrote:
> Hi Patrick and Stefan
> 
> On 12/02/2024 07:15, Patrick Steinhardt wrote:
>> On Sat, Feb 10, 2024 at 10:23:16AM +0100, Stefan Haller wrote:
>>> On 09.02.24 17:24, Phillip Wood wrote:
>>> Yes, I'm familiar with all this, but that's not what I mean. I don't
>>> want to maintain the topology here, and I'm also not suggesting that git
>>> itself generates such "pick" entries with -mX arguments (maybe I wasn't
>>> clear on that). What I want to do is to add such entries myself, as a
>>> user, resulting in the equivalent of doing a "break" at that point in
>>> the rebase and doing a "git cherry-pick -mX <hash-of-merge-commit>"
>>> manually.
>>
>> It would be neat indeed if this could be specified in the instruction
>> sheet. We already support options for the "merge" instruction, so
>> extending "pick" to support options isn't that far-fetched. Then it
>> would become possible to say "pick -m1 fa1afe1".
> 
> It would certainly be possible to extend the sequencer to do that but
> I'm not familiar with why people use "git cherry-pick -m" [1] so I'm
> wondering what this would be used for. It would involve a bit of extra
> complexity so I think we'd want a compelling reason as to why
> cherry-picking merges without maintaining the topology is useful
> especially as one can currently do that via "exec git cherry-pick -m ..."

Ok, I suppose the answer will probably not count as a compelling reason.
My reason for wanting this is that lazygit currently implements
cherry-picking in terms of an interactive rebase, rather then calling
git-cherry-pick. And the reason why it does this is that when you
cherry-pick multiple commits, and one of them conflicts, then you get
lazygit's nice visualization of the rebase todo list to show you where
in the sequence you are, what the conflicting commit is, how many are
left etc. It just happens to support this well for
.git/rebase-merge/git-rebase-todo, but not for .git/sequencer/todo.

It probably makes more sense to teach lazygit to visualize the
.git/sequencer/todo file, and then use git cherry-pick.

See https://github.com/jesseduffield/lazygit/issues/3317

-Stefan

```

## Phillip Wood, 2024-02-26 10:56

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <b4781808-f722-4be5-906f-4c3409c3295c@gmail.com>
URL: https://gitlist.dev/e/b4781808-f722-4be5-906f-4c3409c3295c%40gmail.com
In-Reply-To: <2739325d-93b1-445c-aac9-3e0ec54a27e4@haller-berlin.de>

```
Hi Stefan

On 23/02/2024 20:59, Stefan Haller wrote:
> On 12.02.24 15:38, Phillip Wood wrote:
>> Hi Patrick and Stefan
 >>
>> It would certainly be possible to extend the sequencer to do that but
>> I'm not familiar with why people use "git cherry-pick -m" [1] so I'm
>> wondering what this would be used for. It would involve a bit of extra
>> complexity so I think we'd want a compelling reason as to why
>> cherry-picking merges without maintaining the topology is useful
>> especially as one can currently do that via "exec git cherry-pick -m ..."
> 
> Ok, I suppose the answer will probably not count as a compelling reason.
> My reason for wanting this is that lazygit currently implements
> cherry-picking in terms of an interactive rebase, rather then calling
> git-cherry-pick. And the reason why it does this is that when you
> cherry-pick multiple commits, and one of them conflicts, then you get
> lazygit's nice visualization of the rebase todo list to show you where
> in the sequence you are, what the conflicting commit is, how many are
> left etc. It just happens to support this well for
> .git/rebase-merge/git-rebase-todo, but not for .git/sequencer/todo.

Thanks for the context. I can see how that is convenient for lazygit 
(and makes we think that perhaps we should teach "git status" to show 
pending cherry-picks) but I'm afraid I don't think that is a good reason 
for adding the ability to pick merges to git rebase.

> It probably makes more sense to teach lazygit to visualize the
> .git/sequencer/todo file, and then use git cherry-pick.

If lazygit is generating the todo list for the cherry-pick could it 
check if the commit is a merge and insert "exec cherry-pick -m ..." for 
those commits? The UI could detect that and display something more user 
friendly for those lines in the todo list. It is still more work for 
lazygit but perhaps less than supporting cherry-picks directly.

Best Wishes

Phillip


```

## Stefan Haller, 2024-02-26 19:07

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <6a557891-ffcd-4c42-9768-ec2da0fce92a@haller-berlin.de>
URL: https://gitlist.dev/e/6a557891-ffcd-4c42-9768-ec2da0fce92a%40haller-berlin.de
In-Reply-To: <b4781808-f722-4be5-906f-4c3409c3295c@gmail.com>

```
On 26.02.24 11:56, Phillip Wood wrote:
>> It probably makes more sense to teach lazygit to visualize the
>> .git/sequencer/todo file, and then use git cherry-pick.
> 
> If lazygit is generating the todo list for the cherry-pick could it
> check if the commit is a merge and insert "exec cherry-pick -m ..." for
> those commits?

That's a good idea, but it wouldn't buy us very much. We'd still have to
add support for conflicts during a cherry-pick; when there's a conflict
during a rebase, lazygit has this nice visualization of the conflicting
commit (we talked about that in [1], and it turned out to be working
extremely well), so it would have to learn to do the same thing for a
conflicting cherry-pick (although this does seem to be a lot easier).
And then it would have to learn to call "cherry-pick --continue" rather
than "rebase --continue" after resolving. But if we do all these things,
then we're not so far away from being able to just call git cherry-pick
ourselves.

-Stefan

[1] <https://public-inbox.org/git/
     961e68d7-5f43-c385-10fa-455b8e2f32d0@haller-berlin.de/>

```

## phillip.wood123@gmail.com, 2024-02-27 10:41

Subject: Re: Interactive rebase: using "pick" for merge commits
Message-ID: <2f749aae-697b-4d35-a6ed-7d2a2faa596a@gmail.com>
URL: https://gitlist.dev/e/2f749aae-697b-4d35-a6ed-7d2a2faa596a%40gmail.com
In-Reply-To: <6a557891-ffcd-4c42-9768-ec2da0fce92a@haller-berlin.de>

```
On 26/02/2024 19:07, Stefan Haller wrote:
> On 26.02.24 11:56, Phillip Wood wrote:
>>> It probably makes more sense to teach lazygit to visualize the
>>> .git/sequencer/todo file, and then use git cherry-pick.
>>
>> If lazygit is generating the todo list for the cherry-pick could it
>> check if the commit is a merge and insert "exec cherry-pick -m ..." for
>> those commits?
> 
> That's a good idea, but it wouldn't buy us very much. We'd still have to
> add support for conflicts during a cherry-pick; when there's a conflict
> during a rebase, lazygit has this nice visualization of the conflicting
> commit (we talked about that in [1], and it turned out to be working
> extremely well), so it would have to learn to do the same thing for a
> conflicting cherry-pick (although this does seem to be a lot easier).
> And then it would have to learn to call "cherry-pick --continue" rather
> than "rebase --continue" after resolving. But if we do all these things,
> then we're not so far away from being able to just call git cherry-pick
> ourselves.

Oh I'd forgotten about handling conflicts - that does make my proposal 
less attractive.

Best Wishes

Phillip

> -Stefan
> 
> [1] <https://public-inbox.org/git/
>       961e68d7-5f43-c385-10fa-455b8e2f32d0@haller-berlin.de/>

```
