git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 15/19] t/t5403-post-checkout-hook.sh: convert test -a/-o to && and ||

From
Elia Pinto <gitter.spiros@gmail.com>
Date
May 20, 2014, 13:50 UTC
Message-ID
<1400593832-6510-16-git-send-email-gitter.spiros@gmail.com>
In-Reply-To
<1400593832-6510-1-git-send-email-gitter.spiros@gmail.com>

The interaction with unary operators and operator precedence for && and || are better known than -a and -o, and for that reason we prefer them. Replace all existing instances of -a and -o to save readers from the burden of thinking about such things.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 t/t5403-post-checkout-hook.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
index 1753ef2..fc898c9 100755
--- a/t/t5403-post-checkout-hook.sh
+++ b/t/t5403-post-checkout-hook.sh
@@ -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 ' '
@@ -52,7 +52,7 @@ 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 ' '
@@ -60,7 +60,7 @@ test_expect_success 'post-checkout receives the right args with HEAD changed ' '
 	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 ' '
@@ -68,7 +68,7 @@ test_expect_success 'post-checkout receives the right args when not switching br
 	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
-- 
1.7.10.4
Previous: Elia PintoNext: Elia Pinto
Message 20 of 27 in “convert test -a/-o to && and || patch series”
  1. 00/19 convert test -a/-o to && and || patch seriesElia Pinto, May 20, 2014
  2. 01/19 check_bindir: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  3. Junio C HamanoMay 20, 2014
  4. Junio C HamanoMay 20, 2014
  5. 02/19 contrib/examples/git-clone.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  6. 03/19 contrib/examples/git-commit.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  7. 04/19 contrib/examples/git-merge.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  8. 05/19 contrib/examples/git-repack.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  9. 06/19 contrib/examples/git-resolve.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  10. 07/19 git-bisect.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  11. 08/19 git-mergetool.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  12. 09/19 git-rebase--interactive.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  13. 10/19 git-submodule.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  14. Matthieu MoyMay 20, 2014
  15. Johannes SixtMay 20, 2014
  16. 11/19 t/t0025-crlf-auto.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  17. 12/19 t/t0026-eol-config.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  18. 13/19 t/t4102-apply-rename.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  19. 14/19 t/t5000-tar-tree.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  20. 15/19 t/t5403-post-checkout-hook.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  21. 16/19 t/t5537-fetch-shallow.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  22. 17/19 t/t5538-push-shallow.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  23. 18/19 t/t9814-git-p4-rename.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  24. 19/19 t/test-lib-functions.sh: convert test -a/-o to && and ||Elia Pinto, May 20, 2014
  25. Matthieu MoyMay 20, 2014
  26. Junio C HamanoMay 20, 2014
  27. Jonathan NiederMay 20, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.