]>
Commit | Line | Data |
---|---|---|
34d820ee JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='basic branch output coloring' | |
d6c6b108 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
34d820ee JK |
7 | . ./test-lib.sh |
8 | ||
9 | test_expect_success 'set up some sample branches' ' | |
10 | test_commit foo && | |
654bd7e8 JS |
11 | git branch -M main && |
12 | git update-ref refs/remotes/origin/main HEAD && | |
34d820ee JK |
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' ' | |
34d820ee JK |
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 && | |
654bd7e8 | 26 | * <CYAN>main<RESET> |
34d820ee | 27 | <BLUE>other<RESET> |
654bd7e8 | 28 | <YELLOW>remotes/origin/main<RESET> |
34d820ee | 29 | EOF |
8126b126 | 30 | git branch --color -a >actual.raw && |
34d820ee JK |
31 | test_decode_color <actual.raw >actual && |
32 | test_cmp expect actual | |
33 | ' | |
34 | ||
654bd7e8 | 35 | test_expect_success 'verbose output shows colors' ' |
34d820ee JK |
36 | oid=$(git rev-parse --short HEAD) && |
37 | cat >expect <<-EOF && | |
66713e84 JS |
38 | * <CYAN>main <RESET> $oid foo |
39 | <BLUE>other <RESET> $oid foo | |
40 | <YELLOW>remotes/origin/main<RESET> $oid foo | |
34d820ee | 41 | EOF |
8126b126 | 42 | git branch --color -v -a >actual.raw && |
34d820ee JK |
43 | test_decode_color <actual.raw >actual && |
44 | test_cmp expect actual | |
45 | ' | |
46 | ||
47 | test_done |