Merge branch 'gh/maint-stash-show-error-message' into maint
[git/wpalmer.git] / t / t4026-color.sh
blobd5ccdd0cf8061e797e88185bfddb0864f73291dd
1 #!/bin/sh
3 # Copyright (c) 2008 Timo Hirvonen
6 test_description='Test diff/status color escape codes'
7 . ./test-lib.sh
9 color()
11 actual=$(git config --get-color no.such.slot "$1") &&
12 test "$actual" = "\e$2"
15 invalid_color()
17 test_must_fail git config --get-color no.such.slot "$1"
20 test_expect_success 'reset' '
21 color "reset" "[m"
24 test_expect_success 'attribute before color name' '
25 color "bold red" "[1;31m"
28 test_expect_success 'color name before attribute' '
29 color "red bold" "[1;31m"
32 test_expect_success 'attr fg bg' '
33 color "ul blue red" "[4;34;41m"
36 test_expect_success 'fg attr bg' '
37 color "blue ul red" "[4;34;41m"
40 test_expect_success 'fg bg attr' '
41 color "blue red ul" "[4;34;41m"
44 test_expect_success 'fg bg attr...' '
45 color "blue bold dim ul blink reverse" "[1;2;4;5;7;34m"
48 test_expect_success 'long color specification' '
49 color "254 255 bold dim ul blink reverse" "[1;2;4;5;7;38;5;254;48;5;255m"
52 test_expect_success '256 colors' '
53 color "254 bold 255" "[1;38;5;254;48;5;255m"
56 test_expect_success 'color too small' '
57 invalid_color "-2"
60 test_expect_success 'color too big' '
61 invalid_color "256"
64 test_expect_success 'extra character after color number' '
65 invalid_color "3X"
68 test_expect_success 'extra character after color name' '
69 invalid_color "redX"
72 test_expect_success 'extra character after attribute' '
73 invalid_color "dimX"
76 test_expect_success 'unknown color slots are ignored (diff)' '
77 git config --unset diff.color.new
78 git config color.diff.nosuchslotwilleverbedefined white &&
79 git diff --color
82 test_expect_success 'unknown color slots are ignored (branch)' '
83 git config color.branch.nosuchslotwilleverbedefined white &&
84 git branch -a
87 test_expect_success 'unknown color slots are ignored (status)' '
88 git config color.status.nosuchslotwilleverbedefined white || exit
89 git status
90 case $? in 0|1) : ok ;; *) false ;; esac
93 test_done