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

[PATCH 2/2] rebase: fix preserving commits with --keep-empty

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

When rebasing commits where one or several commits are redundant to commits on the branch that is being rebased upon we error out. This is due to the usage of `--allow-empty` for the invoked cherry-pick command, which will only cause _empty_ commits to be picked instead of also allowing redundant commits. As git-rebase(1) mentions, though, we also want to keep commits that do not change anything from its parents, that is also redundant commits.

Fix this by invoking `git cherry-pick --keep-redundant-commits` instead, which will cause redundant commits to be rebased correctly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 git-rebase--am.sh | 2 +-
 t/t3400-rebase.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index 9ae898b..ea7b897 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -44,7 +44,7 @@ then
 	# empty commits and even if it didn't the format doesn't really lend
 	# itself well to recording empty patches.  fortunately, cherry-pick
 	# makes this easy
-	git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
+	git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --keep-redundant-commits \
 		--right-only "$revisions" \
 		${restrict_revision+^$restrict_revision}
 	ret=$?
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 6cca319..f43b202 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -255,7 +255,7 @@ test_expect_success 'rebase commit with an ancient timestamp' '
 	grep "author .* 34567 +0600$" actual
 '
 
-test_expect_failure 'rebase duplicated commit with --keep-empty' '
+test_expect_success 'rebase duplicated commit with --keep-empty' '
 	git reset --hard &&
 	git checkout master &&
 
-- 
2.6.3
Previous: Patrick SteinhardtNext: Michael Blume
Message 3 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.