t0000: avoid masking git exit value through pipes

9af0b8dbe2 (t0000-basic: more commit-tree tests., 2006-04-26) adds tests for commit-tree that mask the return exit from git as described in a378fee5b07 (Documentation: add shell guidelines, 2018-10-05). Fix the tests, to avoid pipes by using a temporary file instead. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Carlo Marcelo Arenas Belón committed Sep 16, 2021 at 01:55 UTC 66c0c44df617446763845a71a8fe0fab4cb848a9
1 file changed +12 -11
t/t0000-basic.sh
+12 -11
@@ -1271,28 +1271,29 @@ P=$(test_oid root)
1271
1272 test_expect_success 'git commit-tree records the correct tree in a commit' '
1273 commit0=$(echo NO | git commit-tree $P) &&
1274 - tree=$(git show --pretty=raw $commit0 |
1275 - sed -n -e "s/^tree //p" -e "/^author /q") &&
1274 + git show --pretty=raw $commit0 >out &&
1275 + tree=$(sed -n -e "s/^tree //p" -e "/^author /q" out) &&
1276 test "z$tree" = "z$P"
1277 '
1278
1279 test_expect_success 'git commit-tree records the correct parent in a commit' '
1280 commit1=$(echo NO | git commit-tree $P -p $commit0) &&
1281 - parent=$(git show --pretty=raw $commit1 |
1282 - sed -n -e "s/^parent //p" -e "/^author /q") &&
1281 + git show --pretty=raw $commit1 >out &&
1282 + parent=$(sed -n -e "s/^parent //p" -e "/^author /q" out) &&
1283 test "z$commit0" = "z$parent"
1284 '
1285
1286 test_expect_success 'git commit-tree omits duplicated parent in a commit' '
1287 commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&
1288 - parent=$(git show --pretty=raw $commit2 |
1289 - sed -n -e "s/^parent //p" -e "/^author /q" |
1290 - sort -u) &&
1288 + git show --pretty=raw $commit2 >out &&
1289 + cat >match.sed <<-\EOF &&
1290 + s/^parent //p
1291 + /^author /q
1292 + EOF
1293 + parent=$(sed -n -f match.sed out | sort -u) &&
1294 test "z$commit0" = "z$parent" &&
1292 - numparent=$(git show --pretty=raw $commit2 |
1293 - sed -n -e "s/^parent //p" -e "/^author /q" |
1294 - wc -l) &&
1295 - test $numparent = 1
1295 + git show --pretty=raw $commit2 >out &&
1296 + test_stdout_line_count = 1 sed -n -f match.sed out
1297 '
1298
1299 test_expect_success 'update-index D/F conflict' '