diff mbox series

[2/3] t2018: demonstrate checkout -b merge base bug

Message ID ff38bdb5649c3bb028a5227bb0f9569073b8a500.1556226502.git.liu.denton@gmail.com (mailing list archive)
State New, archived
Headers show
Series checkout: allow -b/-B to work on a merge base | expand

Commit Message

Denton Liu April 25, 2019, 9:10 p.m. UTC
In git-checkout.txt, it states

	As a special case, you may use `"A...B"` as a shortcut for the
	merge base of `A` and `B` if there is exactly one merge base. You can
	leave out at most one of `A` and `B`, in which case it defaults to `HEAD`.

However, there exists a bug where performing

	$ git checkout -b test master...

fails with the message

	fatal: Not a valid object name: 'master...'.

Demonstrate this failure so that it can be corrected later.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t2018-checkout-branch.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh
index fdb7fd282d..a3fa520d2e 100755
--- a/t/t2018-checkout-branch.sh
+++ b/t/t2018-checkout-branch.sh
@@ -65,6 +65,12 @@  test_expect_success 'checkout -b to a new branch, set to HEAD' '
 	do_checkout branch2
 '
 
+test_expect_failure 'checkout -b to a merge base' '
+	test_when_finished test_might_fail git branch -D branch2 &&
+	test_when_finished git checkout branch1 &&
+	git checkout -b branch2 branch1...
+'
+
 test_expect_success 'checkout -b to a new branch, set to an explicit ref' '
 	test_when_finished test_might_fail git branch -D branch2 &&
 	test_when_finished git checkout branch1 &&
@@ -122,6 +128,13 @@  test_expect_success 'checkout -B to an existing branch resets branch to HEAD' '
 	do_checkout branch2 "" -B
 '
 
+test_expect_failure 'checkout -B to a merge base' '
+	git checkout branch1 &&
+	git branch -D branch2 &&
+
+	git checkout -B branch2 branch1...
+'
+
 test_expect_success 'checkout -B to an existing branch from detached HEAD resets branch to HEAD' '
 	git checkout $(git rev-parse --verify HEAD) &&