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