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

[PATCH 1/2] rebase: test broken behavior with --keep-empty

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 20, 2015, 12:04 UTC
Message-ID
<1448021080-4994-2-git-send-email-ps@pks.im>
In-Reply-To
<1448021080-4994-1-git-send-email-ps@pks.im>

When a commit is already present in the branch that is being rebased upon we get an empty commit. Usually we just drop this commit, but with `--keep-empty` we want to preserve the commit's message.

Instead of simply applying the empty commit, though, we erroneously end up in cherry-picking mode without any ability to get back to the previous rebase.

The same error happens when we try to rebase a commit with `--keep-empty` that causes a conflict.

Add tests that document this breakage.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t3400-rebase.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 47b5682..6cca319 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -255,4 +255,30 @@ test_expect_success 'rebase commit with an ancient timestamp' '
 	grep "author .* 34567 +0600$" actual
 '
 
+test_expect_failure 'rebase duplicated commit with --keep-empty' '
+	git reset --hard &&
+	git checkout master &&
+
+	>x && git add x && git commit x -mx &&
+	echo x > x && git commit x -mx1 &&
+
+	git checkout -b duplicated HEAD~ &&
+	echo x > x && git commit x -mx2 &&
+	git rebase --keep-empty master
+'
+
+test_expect_failure 'rebase conflicting commit with --keep-empty' '
+	git reset --hard &&
+	git checkout master &&
+
+	echo y > x && git commit x -my &&
+
+	git checkout -b conflict HEAD~ &&
+	echo z > x && git commit x -mz &&
+	test_must_fail git rebase --keep-empty master &&
+
+	git add x &&
+	git rebase --continue
+'
+
 test_done
-- 
2.6.3
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 2 of 5 in “rebase: broken behavior with --keep-empty”
  1. 0/2 rebase: broken behavior with --keep-emptyPatrick Steinhardt, Nov 20, 2015
  2. 1/2 rebase: test broken behavior with --keep-emptyPatrick Steinhardt, Nov 20, 2015
  3. 2/2 rebase: fix preserving commits with --keep-emptyPatrick Steinhardt, Nov 20, 2015
  4. Michael BlumeDec 10, 2015
  5. Patrick SteinhardtDec 14, 2015

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.