sequencer (rebase -i): skip some revert/cherry-pick specific code path
[gitweb.git] / t / t4015-diff-whitespace.sh
index 4da30e5a1ed5e44590a55a46751f70c53512fa44..289806d0c7eb02e0acc5244df5e3999d45b4e085 100755 (executable)
@@ -838,4 +838,138 @@ 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 'ws-error-highlight test setup' '
+
+       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 &&
+
+       cat >expect.default-old <<-\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
+
+       cat >expect.all <<-\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
+
+       cat >expect.none <<-\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_expect_success 'test --ws-error-highlight option' '
+
+       git -c color.diff=always diff --ws-error-highlight=default,old |
+       test_decode_color >current &&
+       test_cmp expect.default-old current &&
+
+       git -c color.diff=always diff --ws-error-highlight=all |
+       test_decode_color >current &&
+       test_cmp expect.all current &&
+
+       git -c color.diff=always diff --ws-error-highlight=none |
+       test_decode_color >current &&
+       test_cmp expect.none current
+
+'
+
+test_expect_success 'test diff.wsErrorHighlight config' '
+
+       git -c color.diff=always -c diff.wsErrorHighlight=default,old diff |
+       test_decode_color >current &&
+       test_cmp expect.default-old current &&
+
+       git -c color.diff=always -c diff.wsErrorHighlight=all diff |
+       test_decode_color >current &&
+       test_cmp expect.all current &&
+
+       git -c color.diff=always -c diff.wsErrorHighlight=none diff |
+       test_decode_color >current &&
+       test_cmp expect.none current
+
+'
+
+test_expect_success 'option overrides diff.wsErrorHighlight' '
+
+       git -c color.diff=always -c diff.wsErrorHighlight=none \
+               diff --ws-error-highlight=default,old |
+       test_decode_color >current &&
+       test_cmp expect.default-old current &&
+
+       git -c color.diff=always -c diff.wsErrorHighlight=default \
+               diff --ws-error-highlight=all |
+       test_decode_color >current &&
+       test_cmp expect.all current &&
+
+       git -c color.diff=always -c diff.wsErrorHighlight=all \
+               diff --ws-error-highlight=none |
+       test_decode_color >current &&
+       test_cmp expect.none current
+
+'
+
 test_done