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

bug in rebase--interactive with squash and conflicts

From
Johannes Sixt <j.sixt@eudaptics.com>
Date
Aug 21, 2007, 15:10 UTC
Message-ID
<46CB004C.AC39D562@eudaptics.com>
Hi,

There's a problem with rebase--interactive where I want to squash two commits and the one to squash is the first in the original series. In particular, I change the commit list from

	pick 1
	pick 2
	pick 3
to
	pick 3
	squash 1
	pick 2

In this case, the edits of commit 3 are lost. There are conflicts when commits 3 and 1 are cherry-picked.

You can simulate the problematic case by applying this patch:
index 40d6799..861ece1 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -252,3 +252,4 @@ 'interrupted squash works as expected' '
 		echo $n >> conflict &&
-		git add conflict &&
+		echo $n > $n
+		git add conflict $n &&
 		git commit -m $n
@@ -256,3 +257,3 @@ 'interrupted squash works as expected' '
 	one=$(git rev-parse HEAD~3) &&
-	! FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
+	! FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 &&
 	(echo one; echo two; echo four) > conflict &&


The test fails now, because git rebase --continue did not fail although
it should have. Run

   gitk HEAD to-be-rebased@{1}

Note that the rebase was completed, i.e. there are now 2 commits instead
of the original 3. But the file 'four' is missing and the final contents
of the file 'conflict' is

one
two
three

i.e. as if commit 3 had never taken place.

-- Hannes
Next: Johannes Schindelin
Message 1 of 3 in “bug in rebase--interactive with squash and conflicts”
  1. Johannes SixtAug 21, 2007
  2. rebase -i: fix squashing corner caseJohannes Schindelin, Aug 23, 2007
  3. Johannes SixtAug 24, 2007

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.