Re: [PATCH] git-rebase: Teach rebase "-" shorthand.

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] git-rebase: Teach rebase "-" shorthand.

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:00:22

Brian Gesiak [off-list ref] writes:
quoted hunk
Teach rebase the same shorthand as checkout and merge; that is, that "-"
means "the branch we were previously on".

Reported-by: Tim Chase <redacted>
Signed-off-by: Brian Gesiak <redacted>
---
 git-rebase.sh     | 4 ++++
 t/t3400-rebase.sh | 6 ++++++
 2 files changed, 10 insertions(+)
diff --git a/git-rebase.sh b/git-rebase.sh
index 5f6732b..2c75e9f 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -453,6 +453,10 @@ then
 		test "$fork_point" = auto && fork_point=t
 		;;
 	*)	upstream_name="$1"
+		if test "$upstream_name" = "-"
+		then
+			upstream_name="@{-1}"
+		fi
 		shift
 		;;
 	esac
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 6d94b1f..00aba9f 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -88,6 +88,12 @@ test_expect_success 'rebase from ambiguous branch name' '
 	git rebase master
 '
 
+test_expect_success 'rebase using shorthand' '
+	git checkout master
+	git checkout -b shorthand HEAD^
+	GIT_TRACE=1 git rebase -
I'd rather not to see that TRACE there.  We would also want to make
sure the result is what we expect to see, not only the command does
not error out, no?
+'
+
 test_expect_success 'rebase a single mode change' '
 	git checkout master &&
 	git branch -D topic &&

[PATCH v2] git-rebase: Teach rebase "-" shorthand.

From: Brian Gesiak <hidden>
Date: 2016-06-15 23:00:22

Teach rebase the same shorthand as checkout and merge; that is, that "-"
means "the branch we were previously on".

Reported-by: Tim Chase <redacted>
Signed-off-by: Brian Gesiak <redacted>
---
 git-rebase.sh     |  4 ++++
 t/t3400-rebase.sh | 11 +++++++++++
 2 files changed, 15 insertions(+)
diff --git a/git-rebase.sh b/git-rebase.sh
index 5f6732b..2c75e9f 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -453,6 +453,10 @@ then
 		test "$fork_point" = auto && fork_point=t
 		;;
 	*)	upstream_name="$1"
+		if test "$upstream_name" = "-"
+		then
+			upstream_name="@{-1}"
+		fi
 		shift
 		;;
 	esac
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 6d94b1f..6176754 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -88,6 +88,17 @@ test_expect_success 'rebase from ambiguous branch name' '
 	git rebase master
 '
 
+test_expect_success 'rebase using shorthand' '
+	git checkout master &&
+	git checkout -b shorthand HEAD^ &&
+	git rebase - 1>shorthand.stdout &&
+	git checkout master &&
+	git branch -D shorthand &&
+	git checkout -b shorthand HEAD^ &&
+	git rebase @{-1} 1>without_shorthand.stdout &&
+	test_i18ncmp without_shorthand.stdout shorthand.stdout
+'
+
 test_expect_success 'rebase a single mode change' '
 	git checkout master &&
 	git branch -D topic &&
-- 
1.8.5.2 (Apple Git-48)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help