Skip to content

Commit 66c0c44

Browse files
carenasgitster
authored andcommitted
t0000: avoid masking git exit value through pipes
9af0b8d (t0000-basic: more commit-tree tests., 2006-04-26) adds tests for commit-tree that mask the return exit from git as described in a378fee (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 637799b commit 66c0c44

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

t/t0000-basic.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,28 +1271,29 @@ P=$(test_oid root)
12711271

12721272
test_expect_success 'git commit-tree records the correct tree in a commit' '
12731273
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) &&
12761276
test "z$tree" = "z$P"
12771277
'
12781278

12791279
test_expect_success 'git commit-tree records the correct parent in a commit' '
12801280
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) &&
12831283
test "z$commit0" = "z$parent"
12841284
'
12851285

12861286
test_expect_success 'git commit-tree omits duplicated parent in a commit' '
12871287
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) &&
12911294
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
12961297
'
12971298

12981299
test_expect_success 'update-index D/F conflict' '

0 commit comments

Comments
 (0)