git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ralf Thielow <ralf.thielow@gmail.com>
To: git@vger.kernel.org
Cc: Ralf Thielow <ralf.thielow@gmail.com>
Subject: [PATCH] rebase: introduce "rebase.preserve" configuration option
Date: Tue,  5 Aug 2014 22:48:34 +0200	[thread overview]
Message-ID: <1407271714-1624-1-git-send-email-ralf.thielow@gmail.com> (raw)

There are several ways to configure Git to preserve merges.
There is "pull.rebase=preserve" for all branches and
"branch.<name>.rebase=preserve" for individual branches.
However, there is no configuration option to preserve merges
for all branches when running git-rebase.

This patch introduces a new configuration variable
"rebase.preserve". If set to true, "--preserve-merges" option
will be enabled in git-rebase by default.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
---
 Documentation/config.txt          |  3 +++
 git-rebase.sh                     |  1 +
 t/t3409-rebase-preserve-merges.sh | 20 ++++++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c08286e..4166be0 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2031,6 +2031,9 @@ rebase.autostash::
 	successful rebase might result in non-trivial conflicts.
 	Defaults to false.
 
+rebase.preserve::
+	If set to true enable '--preserve-merges' option by default.
+
 receive.autogc::
 	By default, git-receive-pack will run "git-gc --auto" after
 	receiving data from git-push and updating refs.  You can stop
diff --git a/git-rebase.sh b/git-rebase.sh
index 47ca3b9..e0b3e05 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -83,6 +83,7 @@ state_dir=
 # One of {'', continue, skip, abort}, as parsed from command line
 action=
 preserve_merges=
+test "$(git config --bool rebase.preserve)" = "true" && preserve_merges=t && interactive_rebase=implied
 autosquash=
 keep_empty=
 test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh
index 8c251c5..3a02240 100755
--- a/t/t3409-rebase-preserve-merges.sh
+++ b/t/t3409-rebase-preserve-merges.sh
@@ -76,6 +76,16 @@ test_expect_success 'setup for merge-preserving rebase' \
 		git merge --no-ff topic2
 	) &&
 
+	git clone ./. clone5 &&
+	(
+		cd clone5 &&
+		git checkout -b topic2 origin/topic &&
+		echo Sixth > A &&
+		git commit -a -m "Modify A3" &&
+		git checkout -b topic origin/topic &&
+		git merge --no-ff topic2
+	) &&
+
 	git checkout topic &&
 	echo Fourth >> B &&
 	git commit -a -m "Modify B2"
@@ -119,4 +129,14 @@ test_expect_success 'rebase -p ignores merge.log config' '
 	)
 '
 
+test_expect_success 'config rebase.preserve preserves no-ff merges' '
+	(
+	cd clone5 &&
+	git fetch &&
+	git -c rebase.preserve=true rebase origin/topic &&
+	test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
+	test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
+	)
+'
+
 test_done
-- 
2.1.0.rc1.205.gf9880d1

             reply	other threads:[~2014-08-05 20:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05 20:48 Ralf Thielow [this message]
2014-08-05 22:39 ` [PATCH] rebase: introduce "rebase.preserve" configuration option Junio C Hamano

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=1407271714-1624-1-git-send-email-ralf.thielow@gmail.com \
    --to=ralf.thielow@gmail.com \
    --cc=git@vger.kernel.org \
    /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).