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

[BUG] rebase -i with only empty commits

From
Stephan Beyer <s-beyer@gmx.net>
Date
Aug 23, 2017, 09:08 UTC
Message-ID
<36e9c381-81b0-ae71-153a-0bcabc59856c@gmx.net>
In-Reply-To
<CAGZ79kYinci-OWXV2VfScLPcUDCHyhSb=7TxTWUWHPnKV5PuDA@mail.gmail.com>
Hi,
On 08/23/2017 01:08 AM, Stefan Beller wrote:
Show 12 quoted lines
> The editor opened proposing the following instruction sheet,
> which in my opinion is buggy:
> 
>     pick 1234 some commit
>     exec make
>     pick 2345 another commit
>     exec make
>     pick 3456 third commit
>     # pick 4567 empty commit
>     exec make
>     pick 5678  yet another commit
>     exec make

This reminds me of another bug I stumbled over recently regarding empty commits.

Do this:
	# repo preparation:
	git init
	:> file1
	git add file1
	git commit -m "add file1"
	:> file2
	git add file2
	git commit -m "add file2"
	# the bug:
	git checkout -b to-be-rebased master^
	git commit --allow-empty -m "empty commit"
	git rebase -i master

It says "Nothing to do". Unsurprisingly, the problem persists when you apply other empty commits:

	git commit --allow-empty -m "another empty commit"
	git rebase -i master
Adding a "real" commit solves the problem:
	:>file3
	git add file3
	git commit -m "add file3"
Adding further empty commits is no problem:
	git commit --allow-empty -m "yet another empty commit"

So the problem seems to be that rebase -i (like rebase without -i) considers "empty commits" as commits to be ignored. However, when using rebase -i one expects that you can include the empty commit...

Also, the behavior is odd. When I only have empty commits, a "git rebase master" works as expected like a "git reset --hard master" but "git rebase -i" does nothing.

The expected behavior would be that the editor shows up with a
git-rebase-todo like:
	# pick 3d0f6c49 empty commit
	# pick bbbc5941 another empty commit
	noop

Thanks Stephan

Previous: Stefan BellerNext: Johannes Schindelin
Message 2 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.