Skip to content

Commit 10acc5f

Browse files
phillipwoodgitster
authored andcommitted
diff --color-moved-ws: demonstrate false positives
'diff --color-moved-ws=allow-indentation-change' can highlight lines that have internal whitespace changes rather than indentation changes. For example in commit 1a07e59 ("Update messages in preparation for i18n", 2018-07-21) the lines - die (_("must end with a color")); + die(_("must end with a color")); are highlighted as moved when they should not be. Modify an existing test to show the problem that will be fixed in the next commit. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b73bcba commit 10acc5f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ test_expect_success 'only move detection ignores white spaces' '
18091809
test_cmp expected actual
18101810
'
18111811

1812-
test_expect_success 'compare whitespace delta across moved blocks' '
1812+
test_expect_failure 'compare whitespace delta across moved blocks' '
18131813
18141814
git reset --hard &&
18151815
q_to_tab <<-\EOF >text.txt &&
@@ -1827,6 +1827,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
18271827
QQQthat has similar lines
18281828
QQQto previous blocks, but with different indent
18291829
QQQYetQAnotherQoutlierQ
1830+
QLine with internal w h i t e s p a c e change
18301831
EOF
18311832
18321833
git add text.txt &&
@@ -1847,6 +1848,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
18471848
QQthat has similar lines
18481849
QQto previous blocks, but with different indent
18491850
QQYetQAnotherQoutlier
1851+
QLine with internal whitespace change
18501852
EOF
18511853
18521854
git diff --color --color-moved --color-moved-ws=allow-indentation-change >actual.raw &&
@@ -1856,7 +1858,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
18561858
<BOLD>diff --git a/text.txt b/text.txt<RESET>
18571859
<BOLD>--- a/text.txt<RESET>
18581860
<BOLD>+++ b/text.txt<RESET>
1859-
<CYAN>@@ -1,14 +1,14 @@<RESET>
1861+
<CYAN>@@ -1,15 +1,15 @@<RESET>
18601862
<BOLD;MAGENTA>-QIndented<RESET>
18611863
<BOLD;MAGENTA>-QText across<RESET>
18621864
<BOLD;MAGENTA>-Qsome lines<RESET>
@@ -1871,6 +1873,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
18711873
<BOLD;MAGENTA>-QQQthat has similar lines<RESET>
18721874
<BOLD;MAGENTA>-QQQto previous blocks, but with different indent<RESET>
18731875
<RED>-QQQYetQAnotherQoutlierQ<RESET>
1876+
<RED>-QLine with internal w h i t e s p a c e change<RESET>
18741877
<BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>Indented<RESET>
18751878
<BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>Text across<RESET>
18761879
<BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>some lines<RESET>
@@ -1885,6 +1888,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
18851888
<BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>that has similar lines<RESET>
18861889
<BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>to previous blocks, but with different indent<RESET>
18871890
<GREEN>+<RESET>QQ<GREEN>YetQAnotherQoutlier<RESET>
1891+
<GREEN>+<RESET>Q<GREEN>Line with internal whitespace change<RESET>
18881892
EOF
18891893
18901894
test_cmp expected actual

0 commit comments

Comments
 (0)