git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] git rebase: Support non-interactive merge-preserving rebase
@ 2008-09-23 20:58 Andreas Ericsson
  0 siblings, 0 replies; only message in thread
From: Andreas Ericsson @ 2008-09-23 20:58 UTC (permalink / raw)
  To: Git Mailing List, Junio C Hamano, Stephen Haberman

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-23 20:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-23 20:58 [PATCH 2/3] git rebase: Support non-interactive merge-preserving rebase Andreas Ericsson

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).