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

[PATCH] t5528: do not fail with FreeBSD shell

From
Kyle J. McKay <mackyle@gmail.com>
Date
Mar 8, 2015, 15:37 UTC
Message-ID
<e3bfc53363b14826d828e1adffbbeea@74d39fa044aa309eaea14b9f57fe79c>
The FreeBSD shell converts this expression:
  git ${1:+-c push.default="$1"} push
to this when "$1" is not empty:
  git "-c push.default=$1" push

which causes git to fail. To avoid this we simply break up the expansion into two parts so that the whitespace which creates two arguments instead of one is outside the ${...} like so:

  git ${1:+-c} ${1:+push.default="$1"} push

This has the desired effect on all platforms allowing the test to pass on FreeBSD.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
---
 t/t5528-push-default.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh
index cc745190..73f4bb63 100755
--- a/t/t5528-push-default.sh
+++ b/t/t5528-push-default.sh
@@ -26,7 +26,7 @@ check_pushed_commit () {
 # $2 = expected target branch for the push
 # $3 = [optional] repo to check for actual output (repo1 by default)
 test_push_success () {
-	git ${1:+-c push.default="$1"} push &&
+	git ${1:+-c} ${1:+push.default="$1"} push &&
 	check_pushed_commit HEAD "$2" "$3"
 }
 
@@ -34,7 +34,7 @@ test_push_success () {
 # check that push fails and does not modify any remote branch
 test_push_failure () {
 	git --git-dir=repo1 log --no-walk --format='%h %s' --all >expect &&
-	test_must_fail git ${1:+-c push.default="$1"} push &&
+	test_must_fail git ${1:+-c} ${1:+push.default="$1"} push &&
 	git --git-dir=repo1 log --no-walk --format='%h %s' --all >actual &&
 	test_cmp expect actual
 }
---
Next: Jeff King
Message 1 of 4 in “t5528: do not fail with FreeBSD shell”
  1. t5528: do not fail with FreeBSD shellKyle J. McKay, Mar 8, 2015
  2. Jeff KingMar 8, 2015
  3. Kyle J. McKayMar 9, 2015
  4. Jeff KingMar 9, 2015

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.