summaryrefslogtreecommitdiff
path: root/t/t2027-checkout-track.sh
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-05-24 07:22:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-24 23:19:41 (GMT)
commit16ab794b8257dd08906994d5cccacfa3886aa543 (patch)
treeec26962828f670b65ceccfe637ee6a4558a0331d /t/t2027-checkout-track.sh
parentae92ac8ae3838e72840f5d019195bb9c0c9e7b0e (diff)
downloadgit-16ab794b8257dd08906994d5cccacfa3886aa543.zip
git-16ab794b8257dd08906994d5cccacfa3886aa543.tar.gz
git-16ab794b8257dd08906994d5cccacfa3886aa543.tar.bz2
checkout: add tests for -b and --track
Test git checkout -b with and without --track and demonstrate unexpected error messages when it's given an extra (i.e. unsupported) path argument. In both cases it reports: $ git checkout -b foo origin/master bar fatal: 'bar' is not a commit and a branch 'foo' cannot be created from it The problem is that the start point we gave for the new branch is "origin/master" and "bar" is just some extra argument -- it could even be a valid commit, which would make the message even more confusing. We have more fitting error messages in git commit, but get confused; use the text of the rights ones in the tests. Reported-by: Dana Dahlstrom <dahlstrom@google.com> Original-test-by: Jeff King <peff@peff.net> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2027-checkout-track.sh')
-rwxr-xr-xt/t2027-checkout-track.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t2027-checkout-track.sh b/t/t2027-checkout-track.sh
new file mode 100755
index 0000000..d0b41d7
--- /dev/null
+++ b/t/t2027-checkout-track.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+test_description='tests for git branch --track'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_commit one &&
+ test_commit two
+'
+
+test_expect_success 'checkout --track -b creates a new tracking branch' '
+ git checkout --track -b branch1 master &&
+ test $(git rev-parse --abbrev-ref HEAD) = branch1 &&
+ test $(git config --get branch.branch1.remote) = . &&
+ test $(git config --get branch.branch1.merge) = refs/heads/master
+'
+
+test_expect_failure 'checkout --track -b rejects an extra path argument' '
+ test_must_fail git checkout --track -b branch2 master one.t 2>err &&
+ test_i18ngrep "cannot be used with updating paths" err
+'
+
+test_done