summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-03-07 00:59:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-03-07 00:59:54 (GMT)
commit3710f60a808ad79bfa604405a725e7accc64f743 (patch)
treecc7f02218768e80d8210f4429308f6d925b9163e /t
parent26e3ddcd7530dbb5f7748970ff16120e47d58f31 (diff)
parent0ecb1fc7269e15be890870937b8b639c987abd08 (diff)
downloadgit-3710f60a808ad79bfa604405a725e7accc64f743.zip
git-3710f60a808ad79bfa604405a725e7accc64f743.tar.gz
git-3710f60a808ad79bfa604405a725e7accc64f743.tar.bz2
Merge branch 'du/branch-show-current'
"git branch" learned a new subcommand "--show-current". * du/branch-show-current: branch: introduce --show-current display option
Diffstat (limited to 't')
-rwxr-xr-xt/t3203-branch-output.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index ee67876..be55148 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -100,6 +100,50 @@ test_expect_success 'git branch -v pattern does not show branch summaries' '
test_must_fail git branch -v branch*
'
+test_expect_success 'git branch `--show-current` shows current branch' '
+ cat >expect <<-\EOF &&
+ branch-two
+ EOF
+ git checkout branch-two &&
+ git branch --show-current >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git branch `--show-current` is silent when detached HEAD' '
+ git checkout HEAD^0 &&
+ git branch --show-current >actual &&
+ test_must_be_empty actual
+'
+
+test_expect_success 'git branch `--show-current` works properly when tag exists' '
+ cat >expect <<-\EOF &&
+ branch-and-tag-name
+ EOF
+ test_when_finished "
+ git checkout branch-one
+ git branch -D branch-and-tag-name
+ " &&
+ git checkout -b branch-and-tag-name &&
+ test_when_finished "git tag -d branch-and-tag-name" &&
+ git tag branch-and-tag-name &&
+ git branch --show-current >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git branch `--show-current` works properly with worktrees' '
+ cat >expect <<-\EOF &&
+ branch-one
+ branch-two
+ EOF
+ git checkout branch-one &&
+ git worktree add worktree branch-two &&
+ {
+ git branch --show-current &&
+ git -C worktree branch --show-current
+ } >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'git branch shows detached HEAD properly' '
cat >expect <<EOF &&
* (HEAD detached at $(git rev-parse --short HEAD^0))