git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] rebase -i with only empty commits

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 23, 2017, 18:29 UTC
Message-ID
<xmqqo9r6yw7i.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<565221dd-b66f-8b88-1bdd-8d0d55c4dc96@gmx.net>
Stephan Beyer <s-beyer@gmx.net> writes:
Show 12 quoted lines
> On 08/23/2017 07:29 PM, Stefan Beller wrote:
>> On Wed, Aug 23, 2017 at 8:19 AM, Stephan Beyer <s-beyer@gmx.net> wrote:
>>> On 08/23/2017 04:40 PM, Johannes Schindelin wrote:
>>>> These days, I reflexively type `rebase -ki` instead of `rebase -i`. Maybe
>>>> you want to do that, too?
>>>
>>> That's a very valuable hint, thank you very much!
>> 
>> While -k side steps the original problem, it seems like it would
>> have helped me, too.
>> 
>> Is there any value in discussing turning it on by default?

As we often see on this list, people tend to be blinded by their own needs and fail to strike the right balance when considering the pros and cons of a change that may help their immediate desire, I think there is a value in discussing it, even if the conclusion turns out that it is not a good idea to change the default. Rather, make that "even if" "especially if"---we would reach a reasonable balance between pros and cons and won't have to repeat the discussion.

Show 5 quoted lines
> I also wondered why empty commits are "discriminated" in such a way.
> I first thought that if you rebase branch A onto B but branch A and B
> contain commits with the same changes, then these commits would become
> new empty commits instead of simply being ignored. But I just checked
> this theory and it is now falsified :)

If you add an identical patch on each of your two toy example branches and try to rebase one over the other, an early logic that culls the set of commits to replay based on patch ID will remove them so you would not even see "it has become empty".

I think you can redo your example by having two consecutive commits on one branch, and then make one commit on the other branch whose effect is those two commits' effect combined. Then rebase the latter on top of the former. "cherry-pick A..B" seems to be aware of this more interesting case and allows you to control the behaviour by having --keep-redundant-commits and --allow-empty as two separate options, but it seems there is no similar provision in "rebase".

Previous: Stephan BeyerNext: Philip Oakley
Message 7 of 9 in “[BUG] rebase -i with empty commits + exec”
  1. Stefan BellerAug 22, 2017
  2. [BUG] rebase -i with only empty commitsStephan Beyer, Aug 23, 2017
  3. Johannes SchindelinAug 23, 2017
  4. Stephan BeyerAug 23, 2017
  5. Stefan BellerAug 23, 2017
  6. Stephan BeyerAug 23, 2017
  7. Junio C HamanoAug 23, 2017
  8. Philip OakleyAug 23, 2017
  9. Phillip WoodAug 24, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.