Merge branch 'rs/commit-h-single-parent-cleanup' into next
[gitweb.git] / t / t3203-branch-output.sh
index c6a3ccba1b992cff7412bcf8139da7557981de94..d2aec0f38b7913b27687b332029dc78be59bc182 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='git branch display tests'
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_expect_success 'make commits' '
        echo content >file &&
@@ -89,6 +90,11 @@ test_expect_success 'git branch --list -v pattern shows branch summaries' '
        awk "{print \$NF}" <tmp >actual &&
        test_cmp expect actual
 '
+test_expect_success 'git branch --ignore-case --list -v pattern shows branch summaries' '
+       git branch --list --ignore-case -v BRANCH* >tmp &&
+       awk "{print \$NF}" <tmp >actual &&
+       test_cmp expect actual
+'
 
 test_expect_success 'git branch -v pattern does not show branch summaries' '
        test_must_fail git branch -v branch*
@@ -189,11 +195,79 @@ test_expect_success 'local-branch symrefs shortened properly' '
        git symbolic-ref refs/heads/ref-to-remote refs/remotes/origin/branch-one &&
        cat >expect <<-\EOF &&
          ref-to-branch -> branch-one
-         ref-to-remote -> refs/remotes/origin/branch-one
+         ref-to-remote -> origin/branch-one
        EOF
        git branch >actual.raw &&
        grep ref-to <actual.raw >actual &&
        test_cmp expect actual
 '
 
+test_expect_success 'sort branches, ignore case' '
+       (
+               git init sort-icase &&
+               cd sort-icase &&
+               test_commit initial &&
+               git branch branch-one &&
+               git branch BRANCH-two &&
+               git branch --list | awk "{print \$NF}" >actual &&
+               cat >expected <<-\EOF &&
+               BRANCH-two
+               branch-one
+               master
+               EOF
+               test_cmp expected actual &&
+               git branch --list -i | awk "{print \$NF}" >actual &&
+               cat >expected <<-\EOF &&
+               branch-one
+               BRANCH-two
+               master
+               EOF
+               test_cmp expected actual
+       )
+'
+
+test_expect_success 'git branch --format option' '
+       cat >expect <<-\EOF &&
+       Refname is (HEAD detached from fromtag)
+       Refname is refs/heads/ambiguous
+       Refname is refs/heads/branch-one
+       Refname is refs/heads/branch-two
+       Refname is refs/heads/master
+       Refname is refs/heads/ref-to-branch
+       Refname is refs/heads/ref-to-remote
+       EOF
+       git branch --format="Refname is %(refname)" >actual &&
+       test_i18ncmp expect actual
+'
+
+test_expect_success "set up color tests" '
+       echo "<RED>master<RESET>" >expect.color &&
+       echo "master" >expect.bare &&
+       color_args="--format=%(color:red)%(refname:short) --list master"
+'
+
+test_expect_success '%(color) omitted without tty' '
+       TERM=vt100 git branch $color_args >actual.raw &&
+       test_decode_color <actual.raw >actual &&
+       test_cmp expect.bare actual
+'
+
+test_expect_success TTY '%(color) present with tty' '
+       test_terminal env TERM=vt100 git branch $color_args >actual.raw &&
+       test_decode_color <actual.raw >actual &&
+       test_cmp expect.color actual
+'
+
+test_expect_success 'color.branch=always overrides auto-color' '
+       git -c color.branch=always branch $color_args >actual.raw &&
+       test_decode_color <actual.raw >actual &&
+       test_cmp expect.color actual
+'
+
+test_expect_success '--color overrides auto-color' '
+       git branch --color $color_args >actual.raw &&
+       test_decode_color <actual.raw >actual &&
+       test_cmp expect.color actual
+'
+
 test_done