diff mbox series

[03/10] fetch tests: use "local", &&-chaining, style etc.

Message ID patch-03.10-02aad13748e-20220621T222854Z-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series t5510: fix the quoting mess | expand

Commit Message

Ævar Arnfjörð Bjarmason June 21, 2022, 10:34 p.m. UTC
Make use of &&-chaining, the "local" keyword, the more idiomatic "test
-z" over comparison against "" etc. in the
"test_configured_prune_type()" function.

Let's also move the wrapper function to below the function itself. In
e1790f9245f (fetch tests: fetch <url> <spec> as well as fetch
[<remote>], 2018-02-09) placed in there to minimize the diff
size. While it's not incorrect to define these in this order (this
isn't C), it's less confusing this way.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t5510-fetch.sh | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)
diff mbox series

Patch

diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 37e12de2475..799e69dc1b1 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -821,20 +821,15 @@  set_config_tristate () {
 	esac
 }
 
-test_configured_prune () {
-	test_configured_prune_type "$@" "name"
-	test_configured_prune_type "$@" "link"
-}
-
 test_configured_prune_type () {
-	fetch_prune=$1
-	remote_origin_prune=$2
-	fetch_prune_tags=$3
-	remote_origin_prune_tags=$4
-	expected_branch=$5
-	expected_tag=$6
-	cmdline=$7
-	mode=$8
+	local fetch_prune="$1" &&
+	local remote_origin_prune="$2" &&
+	local fetch_prune_tags="$3" &&
+	local remote_origin_prune_tags="$4" &&
+	local expected_branch="$5" &&
+	local expected_tag="$6" &&
+	local cmdline="$7" &&
+	local mode="$8" &&
 
 	if test -z "$cmdline_setup"
 	then
@@ -843,18 +838,18 @@  test_configured_prune_type () {
 			remote_fetch="$(git -C one config remote.origin.fetch)" &&
 			cmdline_setup="\"$remote_url\" \"$remote_fetch\""
 		'
-	fi
+	fi &&
 
 	if test "$mode" = 'link'
 	then
-		new_cmdline=""
+		new_cmdline="" &&
 
-		if test "$cmdline" = ""
+		if test -z "$cmdline"
 		then
 			new_cmdline=$cmdline_setup
 		else
 			new_cmdline=$(printf "%s" "$cmdline" | perl -pe 's[origin(?!/)]["'"$remote_url"'"]g')
-		fi
+		fi &&
 
 		if test "$fetch_prune_tags" = 'true' ||
 		   test "$remote_origin_prune_tags" = 'true'
@@ -863,10 +858,10 @@  test_configured_prune_type () {
 			then
 				new_cmdline="$new_cmdline refs/tags/*:refs/tags/*"
 			fi
-		fi
+		fi &&
 
 		cmdline="$new_cmdline"
-	fi
+	fi &&
 
 	test_expect_success "$mode prune fetch.prune=$fetch_prune remote.origin.prune=$remote_origin_prune fetch.pruneTags=$fetch_prune_tags remote.origin.pruneTags=$remote_origin_prune_tags${cmdline:+ $cmdline}; branch:$expected_branch tag:$expected_tag" '
 		# make sure a newbranch is there in . and also in one
@@ -915,6 +910,13 @@  test_configured_prune_type () {
 			esac
 		)
 	'
+
+	return 0
+}
+
+test_configured_prune () {
+	test_configured_prune_type "$@" "name" &&
+	test_configured_prune_type "$@" "link"
 }
 
 # $1 config: fetch.prune