2017-07-09 09:59:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='basic branch output coloring'
|
2021-10-12 13:56:44 +00:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2017-07-09 09:59:33 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'set up some sample branches' '
|
|
|
|
test_commit foo &&
|
2020-12-17 01:07:04 +00:00
|
|
|
git branch -M main &&
|
|
|
|
git update-ref refs/remotes/origin/main HEAD &&
|
2017-07-09 09:59:33 +00:00
|
|
|
git update-ref refs/heads/other HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
# choose non-default colors to make sure config
|
|
|
|
# is taking effect
|
|
|
|
test_expect_success 'set up some color config' '
|
|
|
|
git config color.branch.local blue &&
|
|
|
|
git config color.branch.remote yellow &&
|
|
|
|
git config color.branch.current cyan
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'regular output shows colors' '
|
|
|
|
cat >expect <<-\EOF &&
|
2020-12-17 01:07:04 +00:00
|
|
|
* <CYAN>main<RESET>
|
2017-07-09 09:59:33 +00:00
|
|
|
<BLUE>other<RESET>
|
2020-12-17 01:07:04 +00:00
|
|
|
<YELLOW>remotes/origin/main<RESET>
|
2017-07-09 09:59:33 +00:00
|
|
|
EOF
|
2017-10-03 13:45:18 +00:00
|
|
|
git branch --color -a >actual.raw &&
|
2017-07-09 09:59:33 +00:00
|
|
|
test_decode_color <actual.raw >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2020-12-17 01:07:04 +00:00
|
|
|
test_expect_success 'verbose output shows colors' '
|
2017-07-09 09:59:33 +00:00
|
|
|
oid=$(git rev-parse --short HEAD) &&
|
|
|
|
cat >expect <<-EOF &&
|
2020-10-23 14:00:05 +00:00
|
|
|
* <CYAN>main <RESET> $oid foo
|
|
|
|
<BLUE>other <RESET> $oid foo
|
|
|
|
<YELLOW>remotes/origin/main<RESET> $oid foo
|
2017-07-09 09:59:33 +00:00
|
|
|
EOF
|
2017-10-03 13:45:18 +00:00
|
|
|
git branch --color -v -a >actual.raw &&
|
2017-07-09 09:59:33 +00:00
|
|
|
test_decode_color <actual.raw >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|