Skip to content

Commit

Permalink
t/t5403-post-checkout-hook.sh: avoid "test <cond> -a/-o <cond>"
Browse files Browse the repository at this point in the history
The construct is error-prone; "test" being built-in in most modern
shells, the reason to avoid "test <cond> && test <cond>" spawning
one extra process by using a single "test <cond> -a <cond>" no
longer exists.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Elia Pinto authored and Junio C Hamano committed Jun 9, 2014
1 parent d0b30a3 commit 7281f36
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions t/t5403-post-checkout-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test_expect_success 'post-checkout receives the right arguments with HEAD unchan
old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
test $old = $new -a $flag = 1
test $old = $new && test $flag = 1
'

test_expect_success 'post-checkout runs as expected ' '
Expand All @@ -52,23 +52,23 @@ test_expect_success 'post-checkout args are correct with git checkout -b ' '
old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
test $old = $new -a $flag = 1
test $old = $new && test $flag = 1
'

test_expect_success 'post-checkout receives the right args with HEAD changed ' '
GIT_DIR=clone2/.git git checkout new2 &&
old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
test $old != $new -a $flag = 1
test $old != $new && test $flag = 1
'

test_expect_success 'post-checkout receives the right args when not switching branches ' '
GIT_DIR=clone2/.git git checkout master b &&
old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
test $old = $new -a $flag = 0
test $old = $new && test $flag = 0
'

if test "$(git config --bool core.filemode)" = true; then
Expand Down

0 comments on commit 7281f36

Please sign in to comment.