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

[PATCH 1/3] Prepare for non-interactive merge-preserving rebase

From
Andreas Ericsson <ae@op5.se>
Date
Sep 23, 2008, 20:57 UTC
Message-ID
<48D95836.6040200@op5.se>

This patch adds two tests (really three, but one of them just handles setup) which we currently expect to fail.

One of them tests "git rebase -p", without the -i flag, to make sure it works without phony editors and suchlike.

The other tests "git pull --rebase --preserve-merges" to make sure that the same functionality exists there.

The test was originally written by Stephen Habermann <stephen@exigencecorp.com> but has been significantly modified since its creation.

Signed-off-by: Andreas Ericsson <ae@op5.se>
---

Stephen, I had to modify the tests a bit to get them to work with how I implemented the merge-preserving rebase, and also to remove a lot of the cruft that was previously in there. Hope you're ok with the attribution in the commit message.

 t/t3409-rebase-preserve-merges.sh |   68 +++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100644 t/t3409-rebase-preserve-merges.sh
diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh
new file mode 100644
index 0000000..532b220
--- /dev/null
+++ b/t/t3409-rebase-preserve-merges.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright(C) 2008 Stephen Habermann & Andreas Ericsson
+#
+test_description='git rebase -p should preserve merges
+
+This test runs various incantations of "git rebase -p" and checks
+that merges are properly carried along
+'
+. ./test-lib.sh
+
+GIT_AUTHOR_EMAIL=bogus_email_address
+export GIT_AUTHOR_EMAIL
+
+#echo 'Setting up:
+#
+#A1--A2  <-- origin/master
+# \   \
+#  B1--M  <-- topic
+#   \
+#    B2  <-- origin/topic
+#
+#'
+
+test_expect_success 'setup for merge-preserving rebase' \
+	'echo First > A &&
+	git add A &&
+	git-commit -m "Add A1" &&
+	git checkout -b topic &&
+	echo Second > B &&
+	git add B &&
+	git-commit -m "Add B1" &&
+	git checkout -f master &&
+	echo Third >> A &&
+	git-commit -a -m "Modify A2" &&
+
+	git clone ./. clone1 &&
+	cd clone1 &&
+	git checkout -b topic origin/topic &&
+	git merge origin/master &&
+	cd ..
+
+	git clone ./. clone2
+	cd clone2 &&
+	git checkout -b topic origin/topic &&
+	git merge origin/master &&
+	cd .. &&
+
+	git checkout topic &&
+	echo Fourth >> B &&
+	git commit -a -m "Modify B2"
+'
+
+test_expect_failure 'git pull --rebase -p on moved topic' '
+	cd clone1 &&
+	git pull --rebase --preserve-merges &&
+	test $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) = 1
+'
+
+test_expect_failure 'rebase -p merge on moved topic' '
+	cd ../clone2 &&
+	git fetch &&
+	git rebase -p origin/topic &&
+	test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
+	test 1 = $(git rev-list --all --pretty=oneline | grep "Merge commit" | wc -l)
+'
+
+test_done
-- 
1.6.0.2.307.gc4275.dirty
Next: Stephen Haberman
Message 1 of 13 in “Prepare for non-interactive merge-preserving rebase”
  1. 1/3 Prepare for non-interactive merge-preserving rebaseAndreas Ericsson, Sep 23, 2008
  2. Stephen HabermanSep 23, 2008
  3. Andreas EricssonSep 23, 2008
  4. SZEDER GáborSep 24, 2008
  5. Johannes SixtSep 24, 2008
  6. Andreas EricssonSep 24, 2008
  7. Stephen HabermanOct 15, 2008
  8. Andreas EricssonSep 27, 2008
  9. Stephen HabermanSep 27, 2008
  10. Shawn O. PearceSep 29, 2008
  11. Andreas EricssonSep 29, 2008
  12. Shawn O. PearceSep 29, 2008
  13. Add branch.autosetuppreservemerges and branch.<name>.preservemerges.Stephen Haberman, Oct 1, 2008

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.