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 1a07e59c3e ("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>

Phillip Wood committed Nov 23, 2018 at 11:16 UTC 10acc5f750789fcfd38e43810f2c372b134a807c
1 file changed +6 -2
t/t4015-diff-whitespace.sh
+6 -2
@@ -1809,7 +1809,7 @@ test_expect_success 'only move detection ignores white spaces' '
1809 test_cmp expected actual
1810 '
1811
1812 -test_expect_success 'compare whitespace delta across moved blocks' '
1812 +test_expect_failure 'compare whitespace delta across moved blocks' '
1813
1814 git reset --hard &&
1815 q_to_tab <<-\EOF >text.txt &&
@@ -1827,6 +1827,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
1827 QQQthat has similar lines
1828 QQQto previous blocks, but with different indent
1829 QQQYetQAnotherQoutlierQ
1830 + QLine with internal w h i t e s p a c e change
1831 EOF
1832
1833 git add text.txt &&
@@ -1847,6 +1848,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
1848 QQthat has similar lines
1849 QQto previous blocks, but with different indent
1850 QQYetQAnotherQoutlier
1851 + QLine with internal whitespace change
1852 EOF
1853
1854 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' '
1858 <BOLD>diff --git a/text.txt b/text.txt<RESET>
1859 <BOLD>--- a/text.txt<RESET>
1860 <BOLD>+++ b/text.txt<RESET>
1859 - <CYAN>@@ -1,14 +1,14 @@<RESET>
1861 + <CYAN>@@ -1,15 +1,15 @@<RESET>
1862 <BOLD;MAGENTA>-QIndented<RESET>
1863 <BOLD;MAGENTA>-QText across<RESET>
1864 <BOLD;MAGENTA>-Qsome lines<RESET>
@@ -1871,6 +1873,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
1873 <BOLD;MAGENTA>-QQQthat has similar lines<RESET>
1874 <BOLD;MAGENTA>-QQQto previous blocks, but with different indent<RESET>
1875 <RED>-QQQYetQAnotherQoutlierQ<RESET>
1876 + <RED>-QLine with internal w h i t e s p a c e change<RESET>
1877 <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>Indented<RESET>
1878 <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>Text across<RESET>
1879 <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>some lines<RESET>
@@ -1885,6 +1888,7 @@ test_expect_success 'compare whitespace delta across moved blocks' '
1888 <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>that has similar lines<RESET>
1889 <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>to previous blocks, but with different indent<RESET>
1890 <GREEN>+<RESET>QQ<GREEN>YetQAnotherQoutlier<RESET>
1891 + <GREEN>+<RESET>Q<GREEN>Line with internal whitespace change<RESET>
1892 EOF
1893
1894 test_cmp expected actual