add open_nofollow() helper
[git] / t / t3205-branch-color.sh
1 #!/bin/sh
2
3 test_description='basic branch output coloring'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7 . ./test-lib.sh
8
9 test_expect_success 'set up some sample branches' '
10         test_commit foo &&
11         git branch -M main &&
12         git update-ref refs/remotes/origin/main HEAD &&
13         git update-ref refs/heads/other HEAD
14 '
15
16 # choose non-default colors to make sure config
17 # is taking effect
18 test_expect_success 'set up some color config' '
19         git config color.branch.local blue &&
20         git config color.branch.remote yellow &&
21         git config color.branch.current cyan
22 '
23
24 test_expect_success 'regular output shows colors' '
25         cat >expect <<-\EOF &&
26         * <CYAN>main<RESET>
27           <BLUE>other<RESET>
28           <YELLOW>remotes/origin/main<RESET>
29         EOF
30         git branch --color -a >actual.raw &&
31         test_decode_color <actual.raw >actual &&
32         test_cmp expect actual
33 '
34
35 test_expect_success 'verbose output shows colors' '
36         oid=$(git rev-parse --short HEAD) &&
37         cat >expect <<-EOF &&
38         * <CYAN>main               <RESET> $oid foo
39           <BLUE>other              <RESET> $oid foo
40           <YELLOW>remotes/origin/main<RESET> $oid foo
41         EOF
42         git branch --color -v -a >actual.raw &&
43         test_decode_color <actual.raw >actual &&
44         test_cmp expect actual
45 '
46
47 test_done