t2018: don't lose return code of git commands
Fix invocations of git commands so their exit codes are not lost within non-assignment command substitutions. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
Jan 6, 2020 at 23:53 UTC
62e80fcb480d388777a9d6d96d977e02c3e7dd36
1 file changed
+8
-3
t/t2018-checkout-branch.sh
+8
-3
@@ -41,8 +41,12 @@ do_checkout () {
41
test_must_fail git checkout $opts $exp_branch $exp_sha
42
else
43
git checkout $opts $exp_branch $exp_sha &&
44
- test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) &&
45
- test $exp_sha = $(git rev-parse --verify HEAD)
44
+ echo "$exp_ref" >ref.expect &&
45
+ git rev-parse --symbolic-full-name HEAD >ref.actual &&
46
+ test_cmp ref.expect ref.actual &&
47
+ echo "$exp_sha" >sha.expect &&
48
+ git rev-parse --verify HEAD >sha.actual &&
49
+ test_cmp sha.expect sha.actual
50
fi
51
}
52
@@ -162,7 +166,8 @@ test_expect_success 'checkout -B to a merge base' '
166
'
167
168
test_expect_success 'checkout -B to an existing branch from detached HEAD resets branch to HEAD' '
165
- git checkout $(git rev-parse --verify HEAD) &&
169
+ head=$(git rev-parse --verify HEAD) &&
170
+ git checkout "$head" &&
171
172
do_checkout branch2 "" -B
173
'