t/t5100: no need to use 'echo' command substitutions for globbing
[gitweb.git] / t / t4015-diff-whitespace.sh
index 4da30e5a1ed5e44590a55a46751f70c53512fa44..2434157aa7632551e8f7b9db59b34405f8fbefa3 100755 (executable)
@@ -838,4 +838,100 @@ test_expect_success 'diff that introduces a line with only tabs' '
        test_cmp expected current
 '
 
+test_expect_success 'diff that introduces and removes ws breakages' '
+       git reset --hard &&
+       {
+               echo "0. blank-at-eol " &&
+               echo "1. blank-at-eol "
+       } >x &&
+       git commit -a --allow-empty -m preimage &&
+       {
+               echo "0. blank-at-eol " &&
+               echo "1. still-blank-at-eol " &&
+               echo "2. and a new line "
+       } >x &&
+
+       git -c color.diff=always diff |
+       test_decode_color >current &&
+
+       cat >expected <<-\EOF &&
+       <BOLD>diff --git a/x b/x<RESET>
+       <BOLD>index d0233a2..700886e 100644<RESET>
+       <BOLD>--- a/x<RESET>
+       <BOLD>+++ b/x<RESET>
+       <CYAN>@@ -1,2 +1,3 @@<RESET>
+        0. blank-at-eol <RESET>
+       <RED>-1. blank-at-eol <RESET>
+       <GREEN>+<RESET><GREEN>1. still-blank-at-eol<RESET><BLUE> <RESET>
+       <GREEN>+<RESET><GREEN>2. and a new line<RESET><BLUE> <RESET>
+       EOF
+
+       test_cmp expected current
+'
+
+test_expect_success 'the same with --ws-error-highlight' '
+       git reset --hard &&
+       {
+               echo "0. blank-at-eol " &&
+               echo "1. blank-at-eol "
+       } >x &&
+       git commit -a --allow-empty -m preimage &&
+       {
+               echo "0. blank-at-eol " &&
+               echo "1. still-blank-at-eol " &&
+               echo "2. and a new line "
+       } >x &&
+
+       git -c color.diff=always diff --ws-error-highlight=default,old |
+       test_decode_color >current &&
+
+       cat >expected <<-\EOF &&
+       <BOLD>diff --git a/x b/x<RESET>
+       <BOLD>index d0233a2..700886e 100644<RESET>
+       <BOLD>--- a/x<RESET>
+       <BOLD>+++ b/x<RESET>
+       <CYAN>@@ -1,2 +1,3 @@<RESET>
+        0. blank-at-eol <RESET>
+       <RED>-<RESET><RED>1. blank-at-eol<RESET><BLUE> <RESET>
+       <GREEN>+<RESET><GREEN>1. still-blank-at-eol<RESET><BLUE> <RESET>
+       <GREEN>+<RESET><GREEN>2. and a new line<RESET><BLUE> <RESET>
+       EOF
+
+       test_cmp expected current &&
+
+       git -c color.diff=always diff --ws-error-highlight=all |
+       test_decode_color >current &&
+
+       cat >expected <<-\EOF &&
+       <BOLD>diff --git a/x b/x<RESET>
+       <BOLD>index d0233a2..700886e 100644<RESET>
+       <BOLD>--- a/x<RESET>
+       <BOLD>+++ b/x<RESET>
+       <CYAN>@@ -1,2 +1,3 @@<RESET>
+        <RESET>0. blank-at-eol<RESET><BLUE> <RESET>
+       <RED>-<RESET><RED>1. blank-at-eol<RESET><BLUE> <RESET>
+       <GREEN>+<RESET><GREEN>1. still-blank-at-eol<RESET><BLUE> <RESET>
+       <GREEN>+<RESET><GREEN>2. and a new line<RESET><BLUE> <RESET>
+       EOF
+
+       test_cmp expected current &&
+
+       git -c color.diff=always diff --ws-error-highlight=none |
+       test_decode_color >current &&
+
+       cat >expected <<-\EOF &&
+       <BOLD>diff --git a/x b/x<RESET>
+       <BOLD>index d0233a2..700886e 100644<RESET>
+       <BOLD>--- a/x<RESET>
+       <BOLD>+++ b/x<RESET>
+       <CYAN>@@ -1,2 +1,3 @@<RESET>
+        0. blank-at-eol <RESET>
+       <RED>-1. blank-at-eol <RESET>
+       <GREEN>+1. still-blank-at-eol <RESET>
+       <GREEN>+2. and a new line <RESET>
+       EOF
+
+       test_cmp expected current
+'
+
 test_done