X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=t%2Ft4034-diff-words.sh;h=6f7548c3a144ecada6642eccee6b0f687baafb2d;hb=5bebcd4ecba0791cecaa49d30ddd7ca8ffe03627;hp=1c21276c55400c594f71bc01eba17b0d3820b420;hpb=11a1a49a16a52ff9b684a430d68b8982ed313427;p=git.git diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh index 1c21276c5..6f7548c3a 100755 --- a/t/t4034-diff-words.sh +++ b/t/t4034-diff-words.sh @@ -12,19 +12,9 @@ test_expect_success setup ' ' -decrypt_color () { - sed \ - -e 's/.\[1m//g' \ - -e 's/.\[31m//g' \ - -e 's/.\[32m//g' \ - -e 's/.\[35m//g' \ - -e 's/.\[36m//g' \ - -e 's/.\[m//g' -} - word_diff () { test_must_fail git diff --no-index "$@" pre post > output && - decrypt_color < output > output.decrypted && + test_decode_color output.decrypted && test_cmp expect output.decrypted } @@ -49,7 +39,7 @@ cat > expect <<\EOF index 330b04f..5ed8eff 100644 --- a/pre +++ b/post -@@ -1,3 +1,7 @@ +@@ -1,3 +1,7 @@ h(4)h(4),hh[44] a = b + c @@ -65,14 +55,101 @@ test_expect_success 'word diff with runs of whitespace' ' ' +test_expect_success '--word-diff=color' ' + + word_diff --word-diff=color + +' + +test_expect_success '--color --word-diff=color' ' + + word_diff --color --word-diff=color + +' + +sed 's/#.*$//' > expect < expect < expect <diff --git a/pre b/post +index 330b04f..5ed8eff 100644 +--- a/pre ++++ b/post +@@ -1,3 +1,7 @@ +[-h(4)-]{+h(4),hh[44]+} + +a = b + c + +{+aa = a+} + +{+aeff = aeff * ( aaa )+} +EOF + +test_expect_success '--word-diff=plain --color' ' + + word_diff --word-diff=plain --color + +' + cat > expect <<\EOF diff --git a/pre b/post index 330b04f..5ed8eff 100644 --- a/pre +++ b/post -@@ -1 +1 @@ +@@ -1 +1 @@ h(4)h(4),hh[44] -@@ -3,0 +4,4 @@ a = b + c +@@ -3,0 +4,4 @@ a = b + c aa = a @@ -90,7 +167,7 @@ cat > expect <<\EOF index 330b04f..5ed8eff 100644 --- a/pre +++ b/post -@@ -1,3 +1,7 @@ +@@ -1,3 +1,7 @@ h(4),hh[44] a = b + c @@ -126,7 +203,7 @@ cat > expect <<\EOF index 330b04f..5ed8eff 100644 --- a/pre +++ b/post -@@ -1,3 +1,7 @@ +@@ -1,3 +1,7 @@ h(4),hh[44] a = b + c @@ -153,6 +230,25 @@ test_expect_success 'command-line overrides config' ' word_diff --color-words="[a-z]+" ' +cat > expect <<\EOF +diff --git a/pre b/post +index 330b04f..5ed8eff 100644 +--- a/pre ++++ b/post +@@ -1,3 +1,7 @@ +h(4),{+hh+}[44] + +a = b + c + +{+aa = a+} + +{+aeff = aeff * ( aaa+} ) +EOF + +test_expect_success 'command-line overrides config: --word-diff-regex' ' + word_diff --color --word-diff-regex="[a-z]+" +' + cp expect.non-whitespace-is-word expect test_expect_success '.gitattributes override config' ' @@ -168,7 +264,7 @@ cat > expect <<\EOF index 330b04f..5ed8eff 100644 --- a/pre +++ b/post -@@ -1,3 +1,7 @@ +@@ -1,3 +1,7 @@ h(4),hh[44] a = b + c @@ -190,7 +286,7 @@ cat > expect <<\EOF index c29453b..be22f37 100644 --- a/pre +++ b/post -@@ -1 +1 @@ +@@ -1 +1 @@ aaa (aaa) aaa EOF @@ -209,7 +305,7 @@ cat > expect <<\EOF index 289cb9d..2d06f37 100644 --- a/pre +++ b/post -@@ -1 +1 @@ +@@ -1 +1 @@ (: EOF @@ -219,4 +315,20 @@ test_expect_success 'test when words are only removed at the end' ' ' +cat > expect <<\EOF +diff --git a/pre b/post +index 289cb9d..2d06f37 100644 +--- a/pre ++++ b/post +@@ -1 +1 @@ +-(: ++( +EOF + +test_expect_success '--word-diff=none' ' + + word_diff --word-diff=plain --word-diff=none + +' + test_done