Thread (11 messages) 11 messages, 4 authors, 2021-09-16

Re: [PATCH 2/2] t0000: avoid masking git exit value through pipes

From: Taylor Blau <hidden>
Date: 2021-09-16 05:21:21

On Wed, Sep 15, 2021 at 07:37:06PM -0700, Carlo Marcelo Arenas Belón wrote:
9af0b8dbe2 (t0000-basic: more commit-tree tests., 2006-04-26) adds
tets for commit-tree that mask the return exit from git as described
s/tets/tests
quoted hunk ↗ jump to hunk
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index cb87768513..545ff5af13 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1270,26 +1270,31 @@ test_expect_success 'no diff after checkout and git update-index --refresh' '
 P=$(test_oid root)

 test_expect_success 'git commit-tree records the correct tree in a commit' '
-	commit0=$(echo NO | git commit-tree $P) &&
-	tree=$(git show --pretty=raw $commit0 |
-		 sed -n -e "s/^tree //p" -e "/^author /q") &&
+	echo NO | git commit-tree $P >out &&
+	commit0=$(cat out) &&
+	git show --pretty=raw $commit0 >out &&
+	tree=$(cat out | sed -n -e "s/^tree //p" -e "/^author /q") &&
In this and the below tests which had a similar transformation, the
first invocation does not mask its error, since it's on the right-hand
side of a pipe.

But piping "git show" to sed will mask the exit code of the former. So
that makes sense. But I would like to see us avoid an unnecessary
cat-into-pipe and instead redirect out into sed, like "sed -n -e ...
<out".

Thanks,
Taylor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help