aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorBoyd Stephen Smith Jr <bss@iguanasuicide.net>2009-01-20 21:46:57 -0600
committerJunio C Hamano <gitster@pobox.com>2009-01-21 00:51:12 -0800
commit98a4d87b87e9846eafd21ba232cc2b7ba3f718fc (patch)
tree801c8a827250699199969198c34878714fb65617 /t
parent80c49c3de2d5a3aa12b0980a65f1163c8aef0c16 (diff)
downloadgit-98a4d87b87e9846eafd21ba232cc2b7ba3f718fc.tar.gz
git-98a4d87b87e9846eafd21ba232cc2b7ba3f718fc.tar.xz
color-words: Support diff.wordregex config option
When diff is invoked with --color-words (w/o =regex), use the regular expression the user has configured as diff.wordregex. diff drivers configured via attributes take precedence over the diff.wordregex-words setting. If the user wants to change them, they have their own configuration variables. Signed-off-by: Boyd Stephen Smith Jr <bss@iguanasuicide.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t4034-diff-words.sh45
1 files changed, 43 insertions, 2 deletions
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 744221bef..6bcc15308 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -77,6 +77,7 @@ a = b + c<RESET>
<GREEN>aeff = aeff * ( aaa<RESET> )
EOF
+cp expect expect.letter-runs-are-words
test_expect_success 'word diff with a regular expression' '
@@ -92,7 +93,7 @@ post diff=testdriver
EOF
'
-test_expect_success 'option overrides default' '
+test_expect_success 'option overrides .gitattributes' '
word_diff --color-words="[a-z]+"
@@ -112,13 +113,53 @@ a = b + c<RESET>
<GREEN>aeff = aeff * ( aaa )<RESET>
EOF
+cp expect expect.non-whitespace-is-word
-test_expect_success 'use default supplied by driver' '
+test_expect_success 'use regex supplied by driver' '
word_diff --color-words
'
+test_expect_success 'set diff.wordregex option' '
+ git config diff.wordregex "[[:alnum:]]+"
+'
+
+cp expect.letter-runs-are-words expect
+
+test_expect_success 'command-line overrides config' '
+ word_diff --color-words="[a-z]+"
+'
+
+cp expect.non-whitespace-is-word expect
+
+test_expect_success '.gitattributes override config' '
+ word_diff --color-words
+'
+
+test_expect_success 'remove diff driver regex' '
+ git config --unset diff.testdriver.wordregex
+'
+
+cat > expect <<\EOF
+<WHITE>diff --git a/pre b/post<RESET>
+<WHITE>index 330b04f..5ed8eff 100644<RESET>
+<WHITE>--- a/pre<RESET>
+<WHITE>+++ b/post<RESET>
+<BROWN>@@ -1,3 +1,7 @@<RESET>
+h(4),<GREEN>hh[44<RESET>]
+<RESET>
+a = b + c<RESET>
+
+<GREEN>aa = a<RESET>
+
+<GREEN>aeff = aeff * ( aaa<RESET> )
+EOF
+
+test_expect_success 'use configured regex' '
+ word_diff --color-words
+'
+
echo 'aaa (aaa)' > pre
echo 'aaa (aaa) aaa' > post