diff mbox series

[v2,4/9] t3905: remove nested git in command substitution

Message ID 57c21e2461eea8a37456d211f38fb668278cb2ed.1612855690.git.liu.denton@gmail.com (mailing list archive)
State Superseded
Headers show
Series stash show: learn --include-untracked and --only-untracked | expand

Commit Message

Denton Liu Feb. 9, 2021, 7:28 a.m. UTC
If a git command in a nested command substitution fails, it will be
silently ignored since only the return code of the outer command
substitutions is reported. Factor out nested command substitutions so
that the error codes of those commands are reported.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t3905-stash-include-untracked.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Junio C Hamano Feb. 10, 2021, 7:24 a.m. UTC | #1
Denton Liu <liu.denton@gmail.com> writes:

> If a git command in a nested command substitution fails, it will be
> silently ignored since only the return code of the outer command
> substitutions is reported. Factor out nested command substitutions so
> that the error codes of those commands are reported.

Locally this makes sense.  We may want to clean it up further by
using existing blob objects, instead of using hash-objects, but that
is for some other day.
diff mbox series

Patch

diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 892a2c8057..f008e5d945 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -36,8 +36,10 @@  test_expect_success 'stash save --include-untracked cleaned the untracked files'
 '
 
 test_expect_success 'stash save --include-untracked stashed the untracked files' '
-	tracked=$(git rev-parse --short $(echo 1 | git hash-object --stdin)) &&
-	untracked=$(git rev-parse --short $(echo untracked | git hash-object --stdin)) &&
+	one_blob=$(echo 1 | git hash-object --stdin) &&
+	tracked=$(git rev-parse --short "$one_blob") &&
+	untracked_blob=$(echo untracked | git hash-object --stdin) &&
+	untracked=$(git rev-parse --short "$untracked_blob") &&
 	cat >expect.diff <<-EOF &&
 	diff --git a/HEAD b/HEAD
 	new file mode 100644
@@ -117,7 +119,8 @@  test_expect_success 'stash save -u dirty index' '
 '
 
 test_expect_success 'stash save --include-untracked dirty index got stashed' '
-	blob=$(git rev-parse --short $(echo 4 | git hash-object --stdin)) &&
+	four_blob=$(echo 4 | git hash-object --stdin) &&
+	blob=$(git rev-parse --short "$four_blob") &&
 	cat >expect <<-EOF &&
 	diff --git a/file3 b/file3
 	new file mode 100644