]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3205-branch-color.sh
tests: mark tests relying on the current default for `init.defaultBranch`
[thirdparty/git.git] / t / t3205-branch-color.sh
1 #!/bin/sh
2
3 test_description='basic branch output coloring'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
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 update-ref refs/remotes/origin/master HEAD &&
12 git update-ref refs/heads/other HEAD
13 '
14
15 # choose non-default colors to make sure config
16 # is taking effect
17 test_expect_success 'set up some color config' '
18 git config color.branch.local blue &&
19 git config color.branch.remote yellow &&
20 git config color.branch.current cyan
21 '
22
23 test_expect_success 'regular output shows colors' '
24 cat >expect <<-\EOF &&
25 * <CYAN>master<RESET>
26 <BLUE>other<RESET>
27 <YELLOW>remotes/origin/master<RESET>
28 EOF
29 git branch --color -a >actual.raw &&
30 test_decode_color <actual.raw >actual &&
31 test_cmp expect actual
32 '
33
34 test_expect_success PREPARE_FOR_MAIN_BRANCH 'verbose output shows colors' '
35 oid=$(git rev-parse --short HEAD) &&
36 cat >expect <<-EOF &&
37 * <CYAN>main <RESET> $oid foo
38 <BLUE>other <RESET> $oid foo
39 <YELLOW>remotes/origin/main<RESET> $oid foo
40 EOF
41 git branch --color -v -a >actual.raw &&
42 test_decode_color <actual.raw >actual &&
43 test_cmp expect actual
44 '
45
46 test_done