1#!/bin/sh 2 3test_description='basic branch output coloring' 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 6 7TEST_PASSES_SANITIZE_LEAK=true 8. ./test-lib.sh 9 10test_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 15' 16 17# choose non-default colors to make sure config 18# is taking effect 19test_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 23' 24 25test_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 34' 35 36test_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 46' 47 48test_done 49