sideband: do not read beyond the end of input
[git/git.git] / t / t5409-colorize-remote-messages.sh
CommitLineData
bf1a11f0
HWN
1#!/bin/sh
2
3test_description='remote messages are colorized on the client'
4
5. ./test-lib.sh
6
7test_expect_success 'setup' '
8 mkdir .git/hooks &&
9 write_script .git/hooks/update <<-\EOF &&
10 echo error: error
11 echo ERROR: also highlighted
12 echo hint: hint
13 echo hinting: not highlighted
14 echo success: success
15 echo warning: warning
16 echo prefixerror: error
17 echo " " "error: leading space"
59a255ae
JH
18 echo " "
19 echo Err
bf1a11f0
HWN
20 exit 0
21 EOF
22 echo 1 >file &&
23 git add file &&
24 git commit -m 1 &&
25 git clone . child &&
26 (
27 cd child &&
28 test_commit message2 file content2
29 )
30'
31
32test_expect_success 'keywords' '
33 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/keywords 2>output &&
34 test_decode_color <output >decoded &&
35 grep "<BOLD;RED>error<RESET>: error" decoded &&
36 grep "<YELLOW>hint<RESET>:" decoded &&
37 grep "<BOLD;GREEN>success<RESET>:" decoded &&
38 grep "<BOLD;YELLOW>warning<RESET>:" decoded
39'
40
41test_expect_success 'whole words at line start' '
42 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/whole-words 2>output &&
43 test_decode_color <output >decoded &&
44 grep "<YELLOW>hint<RESET>:" decoded &&
45 grep "hinting: not highlighted" decoded &&
46 grep "prefixerror: error" decoded
47'
48
59a255ae
JH
49test_expect_success 'short line' '
50 git -C child -c color.remote=always push -f origin HEAD:short-line 2>output &&
51 test_decode_color <output >decoded &&
52 grep "remote: Err" decoded
53'
54
bf1a11f0
HWN
55test_expect_success 'case-insensitive' '
56 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/case-insensitive 2>output &&
57 cat output &&
58 test_decode_color <output >decoded &&
59 grep "<BOLD;RED>error<RESET>: error" decoded &&
60 grep "<BOLD;RED>ERROR<RESET>: also highlighted" decoded
61'
62
63test_expect_success 'leading space' '
64 git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/leading-space 2>output && cat output &&
65 test_decode_color <output >decoded &&
66 grep " <BOLD;RED>error<RESET>: leading space" decoded
67'
68
59a255ae
JH
69test_expect_success 'spaces only' '
70 git -C child -c color.remote=always push -f origin HEAD:only-space 2>output &&
71 test_decode_color <output >decoded &&
72 grep "remote: " decoded
73'
74
bf1a11f0
HWN
75test_expect_success 'no coloring for redirected output' '
76 git --git-dir child/.git push -f origin HEAD:refs/heads/redirected-output 2>output &&
77 test_decode_color <output >decoded &&
78 grep "error: error" decoded
79'
80
81test_expect_success 'push with customized color' '
82 git --git-dir child/.git -c color.remote=always -c color.remote.error=blue push -f origin HEAD:refs/heads/customized-color 2>output &&
83 test_decode_color <output >decoded &&
84 grep "<BLUE>error<RESET>:" decoded &&
85 grep "<BOLD;GREEN>success<RESET>:" decoded
86'
87
88
89test_expect_success 'error in customized color' '
90 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 &&
91 test_decode_color <output >decoded &&
92 grep "<BOLD;GREEN>success<RESET>:" decoded
93'
94
95test_expect_success 'fallback to color.ui' '
96 git --git-dir child/.git -c color.ui=always push -f origin HEAD:refs/heads/fallback-color-ui 2>output &&
97 test_decode_color <output >decoded &&
98 grep "<BOLD;RED>error<RESET>: error" decoded
99'
100
101test_done