t4015: refactor --color-moved whitespace test

In preparation for testing several different whitespace options, let's split out the setup and cleanup steps of the whitespace test. While we're here, let's also switch to using "<<-" to indent our here-documents properly, and use q_to_tab to more explicitly mark where we expect whitespace to appear. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 19, 2017 at 16:24 UTC ecd512582cc40b732be342c49b9cb311a6dabc77
1 file changed +29 -20
t/t4015-diff-whitespace.sh
+29 -20
@@ -1318,30 +1318,34 @@ test_expect_success 'no effect from --color-moved with --word-diff' '
1318 test_cmp expect actual
1319 '
1320
1321 -test_expect_success 'move detection ignoring whitespace ' '
1321 +test_expect_success 'set up whitespace tests' '
1322 git reset --hard &&
1323 - cat <<\EOF >lines.txt &&
1324 -line 1
1325 -line 2
1326 -line 3
1327 -line 4
1328 -long line 5
1329 -long line 6
1330 -long line 7
1331 -EOF
1332 - git add lines.txt &&
1333 - git commit -m "add poetry" &&
1334 - cat <<\EOF >lines.txt &&
1323 + # Note that these lines have no leading or trailing whitespace.
1324 + cat <<-\EOF >lines.txt &&
1325 + line 1
1326 + line 2
1327 + line 3
1328 + line 4
1329 long line 5
1330 long line 6
1331 long line 7
1338 -line 1
1339 -line 2
1340 -line 3
1341 -line 4
1342 -EOF
1343 - test_config color.diff.oldMoved "magenta" &&
1344 - test_config color.diff.newMoved "cyan" &&
1332 + EOF
1333 + git add lines.txt &&
1334 + git commit -m "add poetry" &&
1335 + git config color.diff.oldMoved "magenta" &&
1336 + git config color.diff.newMoved "cyan"
1337 +'
1338 +
1339 +test_expect_success 'move detection ignoring whitespace ' '
1340 + q_to_tab <<-\EOF >lines.txt &&
1341 + Qlong line 5
1342 + Qlong line 6
1343 + Qlong line 7
1344 + line 1
1345 + line 2
1346 + line 3
1347 + line 4
1348 + EOF
1349 git diff HEAD --no-renames --color-moved --color |
1350 grep -v "index" |
1351 test_decode_color >actual &&
@@ -1385,6 +1389,11 @@ EOF
1389 test_cmp expected actual
1390 '
1391
1392 +test_expect_success 'clean up whitespace-test colors' '
1393 + git config --unset color.diff.oldMoved &&
1394 + git config --unset color.diff.newMoved
1395 +'
1396 +
1397 test_expect_success '--color-moved block at end of diff output respects MIN_ALNUM_COUNT' '
1398 git reset --hard &&
1399 >bar &&