From 86b452e2769e80b220327b1301c7487ad4afa4f4 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Fri, 30 Jun 2017 13:53:09 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- t/t4015-diff-whitespace.sh | 124 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) (limited to 't') 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 && + diff --git a/lines.txt b/lines.txt + index 47ea9c3..ba96a38 100644 + --- a/lines.txt + +++ b/lines.txt + @@ -1,16 +1,16 @@ + -line 1 + -line 2 + -line 3 + 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 + -line 14 + -line 15 + -line 16 + 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 && + diff --git a/lines.txt b/lines.txt + index 47ea9c3..ba96a38 100644 + --- a/lines.txt + +++ b/lines.txt + @@ -1,16 +1,16 @@ + -line 1 + -line 2 + -line 3 + 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 + -line 14 + -line 15 + -line 16 + 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. -- cgit v1.2.3