3 test_description
='remote messages are colorized on the client'
7 test_expect_success
'setup' '
9 write_script .git/hooks/update <<-\EOF &&
11 echo ERROR: also highlighted
13 echo hinting: not highlighted
16 echo prefixerror: error
17 echo " " "error: leading space"
29 test_commit message2 file content2
33 test_expect_success
'keywords' '
34 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/keywords 2>output &&
35 test_decode_color <output >decoded &&
36 grep "<BOLD;RED>error<RESET>: error" decoded &&
37 grep "<YELLOW>hint<RESET>:" decoded &&
38 grep "<BOLD;GREEN>success<RESET>:" decoded &&
39 grep "<BOLD;GREEN>SUCCESS<RESET>" decoded &&
40 grep "<BOLD;YELLOW>warning<RESET>:" decoded
43 test_expect_success
'whole words at line start' '
44 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/whole-words 2>output &&
45 test_decode_color <output >decoded &&
46 grep "<YELLOW>hint<RESET>:" decoded &&
47 grep "hinting: not highlighted" decoded &&
48 grep "prefixerror: error" decoded
51 test_expect_success
'short line' '
52 git -C child -c color.remote=always push -f origin HEAD:short-line 2>output &&
53 test_decode_color <output >decoded &&
54 grep "remote: Err" decoded
57 test_expect_success
'case-insensitive' '
58 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/case-insensitive 2>output &&
59 test_decode_color <output >decoded &&
60 grep "<BOLD;RED>error<RESET>: error" decoded &&
61 grep "<BOLD;RED>ERROR<RESET>: also highlighted" decoded
64 test_expect_success
'leading space' '
65 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output &&
66 test_decode_color <output >decoded &&
67 grep " <BOLD;RED>error<RESET>: leading space" decoded
70 test_expect_success
'spaces only' '
71 git -C child -c color.remote=always push -f origin HEAD:only-space 2>output &&
72 test_decode_color <output >decoded &&
73 grep "remote: " decoded
76 test_expect_success
'no coloring for redirected output' '
77 git --git-dir child/.git push -f origin HEAD:refs/heads/redirected-output 2>output &&
78 test_decode_color <output >decoded &&
79 grep "error: error" decoded
82 test_expect_success
'push with customized color' '
83 git --git-dir child/.git -c color.remote=always -c color.remote.error=blue push -f origin HEAD:refs/heads/customized-color 2>output &&
84 test_decode_color <output >decoded &&
85 grep "<BLUE>error<RESET>:" decoded &&
86 grep "<BOLD;GREEN>success<RESET>:" decoded
90 test_expect_success
'error in customized color' '
91 git --git-dir child/.git -c color.remote=always -c color.remote.error=i-am-not-a-color push -f origin HEAD:refs/heads/error-customized-color 2>output &&
92 test_decode_color <output >decoded &&
93 grep "<BOLD;GREEN>success<RESET>:" decoded
96 test_expect_success
'fallback to color.ui' '
97 git --git-dir child/.git -c color.ui=always push -f origin HEAD:refs/heads/fallback-color-ui 2>output &&
98 test_decode_color <output >decoded &&
99 grep "<BOLD;RED>error<RESET>: error" decoded