t3701: clean up hunk splitting tests

Clean up some test constructs in preparation for extending the tests in the next commit. There are three small changes, I've grouped them together as they're so small it didn't seem worth creating three separate commits. 1 - "cat file | sed expression" is better written as "sed expression file". 2 - Follow our usual practice of redirecting the output of git commands to a file rather than piping it into another command. 3 - Use test_write_lines rather than 'printf "%s\n"'. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Jan 11, 2022 at 11:12 UTC d16632f6942568019dec21447da1ecc58dba98e0
1 file changed +4 -4
t/t3701-add-interactive.sh
+4 -4
@@ -347,7 +347,7 @@ test_expect_success 'setup patch' '
347 # Expected output, diff is similar to the patch but w/ diff at the top
348 test_expect_success 'setup expected' '
349 echo diff --git a/file b/file >expected &&
350 - cat patch |sed "/^index/s/ 100644/ 100755/" >>expected &&
350 + sed "/^index/s/ 100644/ 100755/" patch >>expected &&
351 cat >expected-output <<-\EOF
352 --- a/file
353 +++ b/file
@@ -373,9 +373,9 @@ test_expect_success 'setup expected' '
373 test_expect_success 'add first line works' '
374 git commit -am "clear local changes" &&
375 git apply patch &&
376 - printf "%s\n" s y y | git add -p file 2>error |
377 - sed -n -e "s/^([1-2]\/[1-2]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
378 - -e "/^[-+@ \\\\]"/p >output &&
376 + test_write_lines s y y | git add -p file 2>error >raw-output &&
377 + sed -n -e "s/^([1-2]\/[1-2]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
378 + -e "/^[-+@ \\\\]"/p raw-output >output &&
379 test_must_be_empty error &&
380 git diff --cached >diff &&
381 diff_cmp expected diff &&