Skip to content

Commit d16632f

Browse files
phillipwoodgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9d7761 commit d16632f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/t3701-add-interactive.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ test_expect_success 'setup patch' '
347347
# Expected output, diff is similar to the patch but w/ diff at the top
348348
test_expect_success 'setup expected' '
349349
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 &&
351351
cat >expected-output <<-\EOF
352352
--- a/file
353353
+++ b/file
@@ -373,9 +373,9 @@ test_expect_success 'setup expected' '
373373
test_expect_success 'add first line works' '
374374
git commit -am "clear local changes" &&
375375
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 &&
379379
test_must_be_empty error &&
380380
git diff --cached >diff &&
381381
diff_cmp expected diff &&

0 commit comments

Comments
 (0)