diff options
Diffstat (limited to 't/t6300-for-each-ref.sh')
| -rwxr-xr-x | t/t6300-for-each-ref.sh | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index 7872a2f544..2274a4b733 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -7,6 +7,7 @@ test_description='for-each-ref test' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh +. "$TEST_DIRECTORY"/lib-terminal.sh # Mon Jul 3 23:18:43 2006 +0000 datestamp=1151968723 @@ -412,19 +413,33 @@ test_expect_success 'Check for invalid refname format' ' test_must_fail git for-each-ref --format="%(refname:INVALID)" ' -cat >expected <<EOF -$(git rev-parse --short refs/heads/master) <GREEN>master<RESET> -$(git rev-parse --short refs/remotes/origin/master) <GREEN>origin/master<RESET> -$(git rev-parse --short refs/tags/testtag) <GREEN>testtag<RESET> -$(git rev-parse --short refs/tags/two) <GREEN>two<RESET> -EOF +test_expect_success 'set up color tests' ' + cat >expected.color <<-EOF && + $(git rev-parse --short refs/heads/master) <GREEN>master<RESET> + $(git rev-parse --short refs/remotes/origin/master) <GREEN>origin/master<RESET> + $(git rev-parse --short refs/tags/testtag) <GREEN>testtag<RESET> + $(git rev-parse --short refs/tags/two) <GREEN>two<RESET> + EOF + sed "s/<[^>]*>//g" <expected.color >expected.bare && + color_format="%(objectname:short) %(color:green)%(refname:short)" +' -test_expect_success 'Check %(color:...) ' ' - git for-each-ref \ - --format="%(objectname:short) %(color:green)%(refname:short)" \ - >actual.raw && +test_expect_success TTY '%(color) shows color with a tty' ' + test_terminal env TERM=vt100 \ + git for-each-ref --format="$color_format" >actual.raw && test_decode_color <actual.raw >actual && - test_cmp expected actual + test_cmp expected.color actual +' + +test_expect_success '%(color) does not show color without tty' ' + TERM=vt100 git for-each-ref --format="$color_format" >actual && + test_cmp expected.bare actual +' + +test_expect_success 'color.ui=always can override tty check' ' + git -c color.ui=always for-each-ref --format="$color_format" >actual.raw && + test_decode_color <actual.raw >actual && + test_cmp expected.color actual ' cat >expected <<\EOF |
