diff.c: add dimming to moved line detection
[git/git.git] / t / t4015-diff-whitespace.sh
index d1d7b99..c3b6974 100755 (executable)
@@ -1179,6 +1179,130 @@ test_expect_success 'plain moved code, inside file' '
        test_cmp expected actual
 '
 
+test_expect_success 'detect permutations inside moved code -- dimmed_zebra' '
+       git reset --hard &&
+       cat <<-\EOF >lines.txt &&
+               line 1
+               line 2
+               line 3
+               line 4
+               line 5
+               line 6
+               line 7
+               line 8
+               line 9
+               line 10
+               line 11
+               line 12
+               line 13
+               line 14
+               line 15
+               line 16
+       EOF
+       git add lines.txt &&
+       git commit -m "add poetry" &&
+       cat <<-\EOF >lines.txt &&
+               line 4
+               line 5
+               line 6
+               line 7
+               line 8
+               line 9
+               line 1
+               line 2
+               line 3
+               line 14
+               line 15
+               line 16
+               line 10
+               line 11
+               line 12
+               line 13
+       EOF
+       test_config color.diff.oldMoved "magenta" &&
+       test_config color.diff.newMoved "cyan" &&
+       test_config color.diff.oldMovedAlternative "blue" &&
+       test_config color.diff.newMovedAlternative "yellow" &&
+       test_config color.diff.oldMovedDimmed "normal magenta" &&
+       test_config color.diff.newMovedDimmed "normal cyan" &&
+       test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
+       test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
+       git diff HEAD --no-renames --color-moved=dimmed_zebra| test_decode_color >actual &&
+       cat <<-\EOF >expected &&
+       <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
+       <BOLD>index 47ea9c3..ba96a38 100644<RESET>
+       <BOLD>--- a/lines.txt<RESET>
+       <BOLD>+++ b/lines.txt<RESET>
+       <CYAN>@@ -1,16 +1,16 @@<RESET>
+       <BMAGENTA>-line 1<RESET>
+       <BMAGENTA>-line 2<RESET>
+       <BMAGENTA>-line 3<RESET>
+        line 4<RESET>
+        line 5<RESET>
+        line 6<RESET>
+        line 7<RESET>
+        line 8<RESET>
+        line 9<RESET>
+       <BCYAN>+<RESET><BCYAN>line 1<RESET>
+       <BCYAN>+<RESET><BCYAN>line 2<RESET>
+       <CYAN>+<RESET><CYAN>line 3<RESET>
+       <YELLOW>+<RESET><YELLOW>line 14<RESET>
+       <BYELLOW>+<RESET><BYELLOW>line 15<RESET>
+       <BYELLOW>+<RESET><BYELLOW>line 16<RESET>
+        line 10<RESET>
+        line 11<RESET>
+        line 12<RESET>
+        line 13<RESET>
+       <BMAGENTA>-line 14<RESET>
+       <BMAGENTA>-line 15<RESET>
+       <BMAGENTA>-line 16<RESET>
+       EOF
+       test_cmp expected actual
+'
+
+test_expect_success 'cmd option assumes configured colored-moved' '
+       test_config color.diff.oldMoved "magenta" &&
+       test_config color.diff.newMoved "cyan" &&
+       test_config color.diff.oldMovedAlternative "blue" &&
+       test_config color.diff.newMovedAlternative "yellow" &&
+       test_config color.diff.oldMovedDimmed "normal magenta" &&
+       test_config color.diff.newMovedDimmed "normal cyan" &&
+       test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
+       test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
+       test_config diff.colorMoved zebra &&
+       git diff HEAD --no-renames --color-moved| test_decode_color >actual &&
+       cat <<-\EOF >expected &&
+       <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
+       <BOLD>index 47ea9c3..ba96a38 100644<RESET>
+       <BOLD>--- a/lines.txt<RESET>
+       <BOLD>+++ b/lines.txt<RESET>
+       <CYAN>@@ -1,16 +1,16 @@<RESET>
+       <MAGENTA>-line 1<RESET>
+       <MAGENTA>-line 2<RESET>
+       <MAGENTA>-line 3<RESET>
+        line 4<RESET>
+        line 5<RESET>
+        line 6<RESET>
+        line 7<RESET>
+        line 8<RESET>
+        line 9<RESET>
+       <CYAN>+<RESET><CYAN>line 1<RESET>
+       <CYAN>+<RESET><CYAN>line 2<RESET>
+       <CYAN>+<RESET><CYAN>line 3<RESET>
+       <YELLOW>+<RESET><YELLOW>line 14<RESET>
+       <YELLOW>+<RESET><YELLOW>line 15<RESET>
+       <YELLOW>+<RESET><YELLOW>line 16<RESET>
+        line 10<RESET>
+        line 11<RESET>
+        line 12<RESET>
+        line 13<RESET>
+       <MAGENTA>-line 14<RESET>
+       <MAGENTA>-line 15<RESET>
+       <MAGENTA>-line 16<RESET>
+       EOF
+       test_cmp expected actual
+'
+
 test_expect_success 'no effect from --color-moved with --word-diff' '
        cat <<-\EOF >text.txt &&
        Lorem Ipsum is simply dummy text of the printing and typesetting industry.