git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Scarborough <alex@gameclay.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Michael Haggerty <mhagger@alum.mit.edu>,
	Alex Scarborough <alex@gameclay.com>
Subject: [PATCH] rebase -p: Preserve fast-forwardable merges
Date: Fri, 22 Jan 2010 23:29:26 -0800	[thread overview]
Message-ID: <dd10f5481001222329i58e7b709m2c547c74161b6771@mail.gmail.com> (raw)

Previously, rebase -p would not preserve a merge commit if the merge
could be resolved as a fast-forward.  rebase -p now passes --no-ff to
git merge when recreating a merge commit, which ensures that merge
commits created with git merge --no-ff are preserved.

Signed-off-by: Alex Scarborough <alex@gameclay.com>
---
First patch, so here's hoping neither I nor my mail client messed up
too much.

This patch will not apply cleanly to branches which do not have
mh/rebase-fixup merged in, as that series removed the wrap of the
line I changed.

 git-rebase--interactive.sh                         |    2 +-
 t/t3416-rebase-preserve-fast-forwardable-merges.sh |   41 ++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletions(-)
 create mode 100755 t/t3416-rebase-preserve-fast-forwardable-merges.sh

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c2f6089..a7a2acc 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -343,7 +343,7 @@ pick_one_preserving_merges () {
 			# No point in merging the first parent, that's HEAD
 			new_parents=${new_parents# $first_parent}
 			if ! do_with_author output \
-				git merge $STRATEGY -m "$msg" $new_parents
+				git merge --no-ff $STRATEGY -m "$msg" $new_parents
 			then
 				printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
 				die_with_patch $sha1 "Error redoing merge $sha1"
diff --git a/t/t3416-rebase-preserve-fast-forwardable-merges.sh
b/t/t3416-rebase-preserve-fast-forwardable-merges.sh
new file mode 100755
index 0000000..d46bf91
--- /dev/null
+++ b/t/t3416-rebase-preserve-fast-forwardable-merges.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='git rebase preserve fastforwardable merges
+
+This test runs git rebase with -p and checks that merges created by
+git merge --no-ff are properly carried along.
+'
+. ./test-lib.sh
+
+# set up three branches like this:
+#
+# A1 - C1 - - - E1
+#   \   \       /
+#    \   -- D1 --
+#     \
+#      -- B1
+
+test_expect_success 'setup' '
+	test_commit A1 &&
+	test_commit B1 &&
+	git reset --hard A1 &&
+	test_commit C1 &&
+	test_commit D1 &&
+	git reset --hard C1 &&
+	test_tick &&
+	git merge --no-ff -m "E1" "D1" &&
+	git tag "E1"
+'
+
+# Should result in:
+#
+# A1 - B1 - C2 - - - E2
+#            \       /
+#             -- D2 --
+#
+test_expect_success 'rebase C1 onto B1' '
+	git rebase -p B1 &&
+	git rev-parse HEAD^2
+'
+
+test_done
-- 
1.6.6

             reply	other threads:[~2010-01-23  7:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-23  7:29 Alex Scarborough [this message]
2010-01-25 14:10 ` [PATCH] rebase -p: Preserve fast-forwardable merges Johannes Schindelin
2010-01-25 18:53   ` Alex Scarborough
2010-01-26 11:14     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dd10f5481001222329i58e7b709m2c547c74161b6771@mail.gmail.com \
    --to=alex@gameclay.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mhagger@alum.mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).