All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Felipe Contreras" <felipe.contreras@gmail.com>
Subject: [PATCH 4/6] test: avoid `path` variable
Date: Tue, 28 Mar 2023 11:39:30 -0600	[thread overview]
Message-ID: <20230328173932.3614601-5-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20230328173932.3614601-1-felipe.contreras@gmail.com>

In zsh it's linked to `PATH`.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t0003-attributes.sh         | 16 ++++++------
 t/t1450-fsck.sh               | 16 ++++++------
 t/t3305-notes-fanout.sh       | 12 ++++-----
 t/t4046-diff-unmerged.sh      | 48 +++++++++++++++++------------------
 t/t5329-pack-objects-cruft.sh |  8 +++---
 5 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 89b306cb11..b956b2fc29 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -7,10 +7,10 @@ TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 attr_check_basic () {
-	path="$1" expect="$2" git_opts="$3" &&
+	fpath="$1" expect="$2" git_opts="$3" &&
 
-	git $git_opts check-attr test -- "$path" >actual 2>err &&
-	echo "$path: test: $expect" >expect &&
+	git $git_opts check-attr test -- "$fpath" >actual 2>err &&
+	echo "$fpath: test: $expect" >expect &&
 	test_cmp expect actual
 }
 
@@ -20,18 +20,18 @@ attr_check () {
 }
 
 attr_check_quote () {
-	path="$1" quoted_path="$2" expect="$3" &&
+	fpath="$1" quoted_path="$2" expect="$3" &&
 
-	git check-attr test -- "$path" >actual &&
+	git check-attr test -- "$fpath" >actual &&
 	echo "\"$quoted_path\": test: $expect" >expect &&
 	test_cmp expect actual
 }
 
 attr_check_source () {
-	path="$1" expect="$2" source="$3" git_opts="$4" &&
+	fpath="$1" expect="$2" source="$3" git_opts="$4" &&
 
-	git $git_opts check-attr --source $source test -- "$path" >actual 2>err &&
-	echo "$path: test: $expect" >expect &&
+	git $git_opts check-attr --source $source test -- "$fpath" >actual 2>err &&
+	echo "$fpath: test: $expect" >expect &&
 	test_cmp expect actual &&
 	test_must_be_empty err
 }
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index bca46378b2..489e03865c 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -589,9 +589,9 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
 	)
 '
 
-while read name path pretty; do
+while read name fpath pretty; do
 	while read mode type; do
-		: ${pretty:=$path}
+		: ${pretty:=$fpath}
 		test_expect_success "fsck notices $pretty as $type" '
 		(
 			git init $name-$type &&
@@ -603,7 +603,7 @@ while read name path pretty; do
 			blob=$(git rev-parse :file) &&
 			tree=$(git rev-parse HEAD^{tree}) &&
 			value=$(eval "echo \$$type") &&
-			printf "$mode $type %s\t%s" "$value" "$path" >bad &&
+			printf "$mode $type %s\t%s" "$value" "$fpath" >bad &&
 			bad_tree=$(git mktree <bad) &&
 			git fsck 2>out &&
 			test_i18ngrep "warning.*tree $bad_tree" out
@@ -674,8 +674,8 @@ create_repo_missing () {
 		unrelated=$(echo unrelated | git hash-object --stdin -w) &&
 		git tag -m foo tag $unrelated &&
 		sha1=$(git rev-parse --verify "$1") &&
-		path=$(echo $sha1 | sed 's|..|&/|') &&
-		rm .git/objects/$path
+		fpath=$(echo $sha1 | sed 's|..|&/|') &&
+		rm .git/objects/$fpath
 	)
 }
 
@@ -781,11 +781,11 @@ test_expect_success 'fsck --name-objects' '
 test_expect_success 'alternate objects are correctly blamed' '
 	test_when_finished "rm -rf alt.git .git/objects/info/alternates" &&
 	name=$(test_oid numeric) &&
-	path=$(test_oid_to_path "$name") &&
+	fpath=$(test_oid_to_path "$name") &&
 	git init --bare alt.git &&
 	echo "../../alt.git/objects" >.git/objects/info/alternates &&
-	mkdir alt.git/objects/$(dirname $path) &&
-	>alt.git/objects/$(dirname $path)/$(basename $path) &&
+	mkdir alt.git/objects/$(dirname $fpath) &&
+	>alt.git/objects/$(dirname $fpath)/$(basename $fpath) &&
 	test_must_fail git fsck >out 2>&1 &&
 	test_i18ngrep alt.git out
 '
diff --git a/t/t3305-notes-fanout.sh b/t/t3305-notes-fanout.sh
index 1ec1fb6715..a0d8ec85a1 100755
--- a/t/t3305-notes-fanout.sh
+++ b/t/t3305-notes-fanout.sh
@@ -6,10 +6,10 @@ TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 path_has_fanout() {
-	path=$1 &&
+	fpath=$1 &&
 	fanout=$2 &&
 	after_last_slash=$(($(test_oid hexsz) - $fanout * 2)) &&
-	echo $path | grep -q -E "^([0-9a-f]{2}/){$fanout}[0-9a-f]{$after_last_slash}$"
+	echo $fpath | grep -q -E "^([0-9a-f]{2}/){$fanout}[0-9a-f]{$after_last_slash}$"
 }
 
 touched_one_note_with_fanout() {
@@ -17,17 +17,17 @@ touched_one_note_with_fanout() {
 	modification=$2 &&  # 'A' for addition, 'D' for deletion
 	fanout=$3 &&
 	diff=$(git diff-tree --no-commit-id --name-status --root -r $notes_commit) &&
-	path=$(echo $diff | sed -e "s/^$modification[\t ]//") &&
-	path_has_fanout "$path" $fanout;
+	fpath=$(echo $diff | sed -e "s/^$modification[\t ]//") &&
+	path_has_fanout "$fpath" $fanout;
 }
 
 all_notes_have_fanout() {
 	notes_commit=$1 &&
 	fanout=$2 &&
 	git ls-tree -r --name-only $notes_commit |
-	while read path
+	while read fpath
 	do
-		path_has_fanout $path $fanout || return 1
+		path_has_fanout $fpath $fanout || return 1
 	done
 }
 
diff --git a/t/t4046-diff-unmerged.sh b/t/t4046-diff-unmerged.sh
index ffaf69335f..4998a1ce27 100755
--- a/t/t4046-diff-unmerged.sh
+++ b/t/t4046-diff-unmerged.sh
@@ -19,10 +19,10 @@ test_expect_success setup '
 		do
 			for t in o x
 			do
-				path="$b$o$t" &&
-				case "$path" in ooo) continue ;; esac &&
-				paths="$paths$path " &&
-				p="	$path" &&
+				fpath="$b$o$t" &&
+				case "$fpath" in ooo) continue ;; esac &&
+				paths="$paths$fpath " &&
+				p="	$fpath" &&
 				case "$b" in x) echo "$m1$p" ;; esac &&
 				case "$o" in x) echo "$m2$p" ;; esac &&
 				case "$t" in x) echo "$m3$p" ;; esac ||
@@ -36,22 +36,22 @@ test_expect_success setup '
 '
 
 test_expect_success 'diff-files -0' '
-	for path in $paths
+	for fpath in $paths
 	do
-		>"$path" &&
-		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$path" || return 1
+		>"$fpath" &&
+		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$fpath" || return 1
 	done >diff-files-0.expect &&
 	git diff-files -0 >diff-files-0.actual &&
 	test_cmp diff-files-0.expect diff-files-0.actual
 '
 
 test_expect_success 'diff-files -1' '
-	for path in $paths
+	for fpath in $paths
 	do
-		>"$path" &&
-		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$path" &&
-		case "$path" in
-		x??) echo ":100644 100644 $blob1 $ZERO_OID M	$path"
+		>"$fpath" &&
+		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$fpath" &&
+		case "$fpath" in
+		x??) echo ":100644 100644 $blob1 $ZERO_OID M	$fpath"
 		esac || return 1
 	done >diff-files-1.expect &&
 	git diff-files -1 >diff-files-1.actual &&
@@ -59,12 +59,12 @@ test_expect_success 'diff-files -1' '
 '
 
 test_expect_success 'diff-files -2' '
-	for path in $paths
+	for fpath in $paths
 	do
-		>"$path" &&
-		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$path" &&
-		case "$path" in
-		?x?) echo ":100644 100644 $blob2 $ZERO_OID M	$path"
+		>"$fpath" &&
+		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$fpath" &&
+		case "$fpath" in
+		?x?) echo ":100644 100644 $blob2 $ZERO_OID M	$fpath"
 		esac || return 1
 	done >diff-files-2.expect &&
 	git diff-files -2 >diff-files-2.actual &&
@@ -74,12 +74,12 @@ test_expect_success 'diff-files -2' '
 '
 
 test_expect_success 'diff-files -3' '
-	for path in $paths
+	for fpath in $paths
 	do
-		>"$path" &&
-		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$path" &&
-		case "$path" in
-		??x) echo ":100644 100644 $blob3 $ZERO_OID M	$path"
+		>"$fpath" &&
+		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$fpath" &&
+		case "$fpath" in
+		??x) echo ":100644 100644 $blob3 $ZERO_OID M	$fpath"
 		esac || return 1
 	done >diff-files-3.expect &&
 	git diff-files -3 >diff-files-3.actual &&
@@ -87,9 +87,9 @@ test_expect_success 'diff-files -3' '
 '
 
 test_expect_success 'diff --stat' '
-	for path in $paths
+	for fpath in $paths
 	do
-		echo " $path | Unmerged" || return 1
+		echo " $fpath | Unmerged" || return 1
 	done >diff-stat.expect &&
 	echo " 0 files changed" >>diff-stat.expect &&
 	git diff --cached --stat >diff-stat.actual &&
diff --git a/t/t5329-pack-objects-cruft.sh b/t/t5329-pack-objects-cruft.sh
index 303f7a5d84..86838d2b0f 100755
--- a/t/t5329-pack-objects-cruft.sh
+++ b/t/t5329-pack-objects-cruft.sh
@@ -28,8 +28,8 @@ basic_cruft_pack_tests () {
 				git rev-list --objects --no-object-names base..loose |
 				while read oid
 				do
-					path="$objdir/$(test_oid_to_path "$oid")" &&
-					printf "%s %d\n" "$oid" "$(test-tool chmtime --get "$path")" ||
+					fpath="$objdir/$(test_oid_to_path "$oid")" &&
+					printf "%s %d\n" "$oid" "$(test-tool chmtime --get "$fpath")" ||
 					echo "object list generation failed for $oid"
 				done |
 				sort -k1
@@ -413,8 +413,8 @@ test_expect_success 'loose objects mtimes upsert others' '
 		git repack &&
 
 		tip="$(git rev-parse cruft)" &&
-		path="$objdir/$(test_oid_to_path "$tip")" &&
-		test-tool chmtime --get +1000 "$path" >expect &&
+		fpath="$objdir/$(test_oid_to_path "$tip")" &&
+		test-tool chmtime --get +1000 "$fpath" >expect &&
 
 		git checkout main &&
 		git branch -D other &&
-- 
2.39.2.13.g1fb56cf030


  parent reply	other threads:[~2023-03-28 17:40 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 17:39 [PATCH 0/6] test: make the test suite work with zsh Felipe Contreras
2023-03-28 17:39 ` [PATCH 1/6] test: fix build for zsh Felipe Contreras
2023-03-28 17:39 ` [PATCH 2/6] test: avoid `stat` variable Felipe Contreras
2023-03-29  9:48   ` Ævar Arnfjörð Bjarmason
2023-04-01  0:05   ` Taylor Blau
2023-04-01  0:25     ` Felipe Contreras
2023-03-28 17:39 ` [PATCH 3/6] test: avoid `options` variable Felipe Contreras
2023-03-28 17:39 ` Felipe Contreras [this message]
2023-03-28 17:39 ` [PATCH 5/6] test: hack for zsh Felipe Contreras
2023-03-30  8:15   ` Felipe Contreras
2023-03-28 17:39 ` [PATCH 6/6] mergetools: vimdiff: check for empty fields Felipe Contreras
2023-03-29  0:57 ` [PATCH 0/6] test: make the test suite work with zsh brian m. carlson
2023-03-29  1:57   ` Felipe Contreras
2023-03-29  9:51     ` Ævar Arnfjörð Bjarmason
2023-03-29 11:19       ` Felipe Contreras
2023-03-30 13:00         ` Felipe Contreras
2023-03-29 15:34   ` Junio C Hamano
2023-03-29 21:54     ` Felipe Contreras
2023-03-30 10:15       ` Junio C Hamano
2023-03-30 14:19         ` Felipe Contreras
2023-04-01  0:04           ` Taylor Blau
2023-04-01  0:59             ` Felipe Contreras
2023-04-01  1:30           ` Junio C Hamano
2023-04-01  2:39             ` Felipe Contreras
2023-04-01  0:00         ` Taylor Blau
2023-04-01  0:50           ` Felipe Contreras
2023-03-29 22:14     ` brian m. carlson
2023-03-30  3:15       ` Junio C Hamano
2023-03-30  7:47         ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230328173932.3614601-5-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.