blob: 0b61da92b37763213e4cee3744f127971cb6fcb1 [file] [log] [blame]
Jeff King34d820e2017-07-09 05:59:33 -04001#!/bin/sh
2
3test_description='basic branch output coloring'
Ævar Arnfjörð Bjarmason288a4802021-10-12 15:56:44 +02004TEST_PASSES_SANITIZE_LEAK=true
Jeff King34d820e2017-07-09 05:59:33 -04005. ./test-lib.sh
6
7test_expect_success 'set up some sample branches' '
8 test_commit foo &&
Johannes Schindelin654bd7e2020-12-17 01:07:04 +00009 git branch -M main &&
10 git update-ref refs/remotes/origin/main HEAD &&
Jeff King34d820e2017-07-09 05:59:33 -040011 git update-ref refs/heads/other HEAD
12'
13
14# choose non-default colors to make sure config
15# is taking effect
16test_expect_success 'set up some color config' '
Jeff King34d820e2017-07-09 05:59:33 -040017 git config color.branch.local blue &&
18 git config color.branch.remote yellow &&
19 git config color.branch.current cyan
20'
21
22test_expect_success 'regular output shows colors' '
23 cat >expect <<-\EOF &&
Johannes Schindelin654bd7e2020-12-17 01:07:04 +000024 * <CYAN>main<RESET>
Jeff King34d820e2017-07-09 05:59:33 -040025 <BLUE>other<RESET>
Johannes Schindelin654bd7e2020-12-17 01:07:04 +000026 <YELLOW>remotes/origin/main<RESET>
Jeff King34d820e2017-07-09 05:59:33 -040027 EOF
Jeff King8126b122017-10-03 09:45:18 -040028 git branch --color -a >actual.raw &&
Jeff King34d820e2017-07-09 05:59:33 -040029 test_decode_color <actual.raw >actual &&
30 test_cmp expect actual
31'
32
Johannes Schindelin654bd7e2020-12-17 01:07:04 +000033test_expect_success 'verbose output shows colors' '
Jeff King34d820e2017-07-09 05:59:33 -040034 oid=$(git rev-parse --short HEAD) &&
35 cat >expect <<-EOF &&
Johannes Schindelin66713e82020-10-23 14:00:05 +000036 * <CYAN>main <RESET> $oid foo
37 <BLUE>other <RESET> $oid foo
38 <YELLOW>remotes/origin/main<RESET> $oid foo
Jeff King34d820e2017-07-09 05:59:33 -040039 EOF
Jeff King8126b122017-10-03 09:45:18 -040040 git branch --color -v -a >actual.raw &&
Jeff King34d820e2017-07-09 05:59:33 -040041 test_decode_color <actual.raw >actual &&
42 test_cmp expect actual
43'
44
45test_done