git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Ericsson <ae@op5.se>
To: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Stephen Haberman <stephen@exigencecorp.com>
Subject: [PATCH 2/3] git rebase: Support non-interactive merge-preserving rebase
Date: Tue, 23 Sep 2008 22:58:16 +0200	[thread overview]
Message-ID: <48D95868.7040308@op5.se> (raw)

Previously, 'git rebase --preserve-merges' would only work
in interactive mode. For some workflows, this was quite a
limitation.

This patch adds a workaround, invoking the
git-rebase--interactive helper with GIT_EDITOR set to :
in case the user passes "-p" but not "-i" to the rebase
command.

The effect is that the interactive rebase helper is used,
but the user won't see an editor.

Since this patch fixes the latter of the two expected
testfailures in t3409-rebase-preserve-merges, that test
is now set to expect success.

Signed-off-by: Andreas Ericsson <ae@op5.se>
---
 Documentation/git-rebase.txt      |    3 +--
 git-rebase.sh                     |   22 +++++++++++++++++++---
 t/t3409-rebase-preserve-merges.sh |    2 +-
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 59c1b02..ddec6a6 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -250,8 +250,7 @@ OPTIONS
 
 -p::
 --preserve-merges::
-	Instead of ignoring merges, try to recreate them.  This option
-	only works in interactive mode.
+	Instead of ignoring merges, try to recreate them.
 
 include::merge-strategies.txt[]
 
diff --git a/git-rebase.sh b/git-rebase.sh
index 528b604..03e5f95 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -138,10 +138,26 @@ finish_rb_merge () {
 }
 
 is_interactive () {
-	test -f "$dotest"/interactive ||
-	while :; do case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac
+	while test $# != 0
+	do
+		case "$1" in
+			-i|--interactive)
+				interactive_rebase=explicit
+				break
+			;;
+			-p|--preserve-merges)
+				interactive_rebase=implied
+			;;
+		esac
 		shift
-	done && test -n "$1"
+	done
+
+	if [ "$interactive_rebase" = implied ]; then
+		GIT_EDITOR=:
+		export GIT_EDITOR
+	fi
+
+	test -n "$interactive_rebase" || test -f "$dotest"/interactive
 }
 
 test -f "$GIT_DIR"/rebase-apply/applying &&
diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh
index 532b220..21b8c79 100644
--- a/t/t3409-rebase-preserve-merges.sh
+++ b/t/t3409-rebase-preserve-merges.sh
@@ -57,7 +57,7 @@ test_expect_failure 'git pull --rebase -p on moved topic' '
 	test $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) = 1
 '
 
-test_expect_failure 'rebase -p merge on moved topic' '
+test_expect_success 'rebase -p merge on moved topic' '
 	cd ../clone2 &&
 	git fetch &&
 	git rebase -p origin/topic &&
-- 
1.6.0.2.307.gc4275.dirty

                 reply	other threads:[~2008-09-23 20:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=48D95868.7040308@op5.se \
    --to=ae@op5.se \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=stephen@exigencecorp.com \
    /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).