color-words: change algorithm to allow for 0-character word boundaries
[git/trast.git] / t / t4034-diff-words.sh
blobb22195f8bbbe369349b24ba1a61734087b476b47
1 #!/bin/sh
3 test_description='word diff colors'
5 . ./test-lib.sh
7 test_expect_success setup '
9 git config diff.color.old red
10 git config diff.color.new green
14 decrypt_color () {
15 sed \
16 -e 's/.\[1m/<WHITE>/g' \
17 -e 's/.\[31m/<RED>/g' \
18 -e 's/.\[32m/<GREEN>/g' \
19 -e 's/.\[36m/<BROWN>/g' \
20 -e 's/.\[m/<RESET>/g'
23 word_diff () {
24 test_must_fail git diff --no-index "$@" pre post > output &&
25 decrypt_color < output > output.decrypted &&
26 test_cmp expect output.decrypted
29 cat > pre <<\EOF
30 h(4)
32 a = b + c
33 EOF
35 cat > post <<\EOF
36 h(4),hh[44]
38 a = b + c
40 aa = a
42 aeff = aeff * ( aaa )
43 EOF
45 cat > expect <<\EOF
46 <WHITE>diff --git a/pre b/post<RESET>
47 <WHITE>index 330b04f..5ed8eff 100644<RESET>
48 <WHITE>--- a/pre<RESET>
49 <WHITE>+++ b/post<RESET>
50 <BROWN>@@ -1,3 +1,7 @@<RESET>
51 <RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
52 <RESET>
53 a = b + c<RESET>
55 <GREEN>aa = a<RESET>
57 <GREEN>aeff = aeff * ( aaa )<RESET>
58 EOF
60 test_expect_success 'word diff with runs of whitespace' '
62 word_diff --color-words
66 test_done