summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-06-30 13:53:09 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-30 13:59:42 -0700
commit86b452e2769e80b220327b1301c7487ad4afa4f4 (patch)
tree4caae0114a2d59d80a7c8cb12f4dc3e27cd7cc08 /t
parent176841f0c9b470b008c95eb50b7bb9424321d540 (diff)
downloadgit-86b452e2769e80b220327b1301c7487ad4afa4f4.tar.gz
diff.c: add dimming to moved line detection
Any lines inside a moved block of code are not interesting. Boundaries of blocks are only interesting if they are next to another block of moved code. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t4015-diff-whitespace.sh124
1 files changed, 124 insertions, 0 deletions
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index d1d7b99990..c3b697411a 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -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.