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

[PATCH v2 2/6] t1404: remove "prefix" argument to test_update_rejected

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Jun 10, 2016, 08:14 UTC
Message-ID
<cd193d74753c0c5e34995dc5c1df1e8881ba5bcb.1465544913.git.mhagger@alum.mit.edu>
In-Reply-To
<cover.1465544913.git.mhagger@alum.mit.edu>

The tests already set a variable called prefix and passed its value as the first argument to this function. The old argument handling was overwriting the global variable with its same value rather than creating a local variable.

So change test_update_rejected to refer to the global variable rather than taking the prefix as an argument.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 t/t1404-update-ref-errors.sh | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/t/t1404-update-ref-errors.sh b/t/t1404-update-ref-errors.sh
index 2818460..541cad1 100755
--- a/t/t1404-update-ref-errors.sh
+++ b/t/t1404-update-ref-errors.sh
@@ -4,11 +4,10 @@ test_description='Test git update-ref error handling'
 . ./test-lib.sh
 
 test_update_rejected () {
-	prefix="$1" &&
-	before="$2" &&
-	pack="$3" &&
-	create="$4" &&
-	error="$5" &&
+	before="$1" &&
+	pack="$2" &&
+	create="$3" &&
+	error="$4" &&
 	printf "create $prefix/%s $C\n" $before |
 	git update-ref --stdin &&
 	git for-each-ref $prefix >unchanged &&
@@ -37,7 +36,7 @@ test_expect_success 'setup' '
 test_expect_success 'existing loose ref is a simple prefix of new' '
 
 	prefix=refs/1l &&
-	test_update_rejected $prefix "a c e" false "b c/x d" \
+	test_update_rejected "a c e" false "b c/x d" \
 		"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"
 
 '
@@ -45,7 +44,7 @@ test_expect_success 'existing loose ref is a simple prefix of new' '
 test_expect_success 'existing packed ref is a simple prefix of new' '
 
 	prefix=refs/1p &&
-	test_update_rejected $prefix "a c e" true "b c/x d" \
+	test_update_rejected "a c e" true "b c/x d" \
 		"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"
 
 '
@@ -53,7 +52,7 @@ test_expect_success 'existing packed ref is a simple prefix of new' '
 test_expect_success 'existing loose ref is a deeper prefix of new' '
 
 	prefix=refs/2l &&
-	test_update_rejected $prefix "a c e" false "b c/x/y d" \
+	test_update_rejected "a c e" false "b c/x/y d" \
 		"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"
 
 '
@@ -61,7 +60,7 @@ test_expect_success 'existing loose ref is a deeper prefix of new' '
 test_expect_success 'existing packed ref is a deeper prefix of new' '
 
 	prefix=refs/2p &&
-	test_update_rejected $prefix "a c e" true "b c/x/y d" \
+	test_update_rejected "a c e" true "b c/x/y d" \
 		"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"
 
 '
@@ -69,7 +68,7 @@ test_expect_success 'existing packed ref is a deeper prefix of new' '
 test_expect_success 'new ref is a simple prefix of existing loose' '
 
 	prefix=refs/3l &&
-	test_update_rejected $prefix "a c/x e" false "b c d" \
+	test_update_rejected "a c/x e" false "b c d" \
 		"$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"
 
 '
@@ -77,7 +76,7 @@ test_expect_success 'new ref is a simple prefix of existing loose' '
 test_expect_success 'new ref is a simple prefix of existing packed' '
 
 	prefix=refs/3p &&
-	test_update_rejected $prefix "a c/x e" true "b c d" \
+	test_update_rejected "a c/x e" true "b c d" \
 		"$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"
 
 '
@@ -85,7 +84,7 @@ test_expect_success 'new ref is a simple prefix of existing packed' '
 test_expect_success 'new ref is a deeper prefix of existing loose' '
 
 	prefix=refs/4l &&
-	test_update_rejected $prefix "a c/x/y e" false "b c d" \
+	test_update_rejected "a c/x/y e" false "b c d" \
 		"$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"
 
 '
@@ -93,7 +92,7 @@ test_expect_success 'new ref is a deeper prefix of existing loose' '
 test_expect_success 'new ref is a deeper prefix of existing packed' '
 
 	prefix=refs/4p &&
-	test_update_rejected $prefix "a c/x/y e" true "b c d" \
+	test_update_rejected "a c/x/y e" true "b c d" \
 		"$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"
 
 '
@@ -101,7 +100,7 @@ test_expect_success 'new ref is a deeper prefix of existing packed' '
 test_expect_success 'one new ref is a simple prefix of another' '
 
 	prefix=refs/5 &&
-	test_update_rejected $prefix "a e" false "b c c/x d" \
+	test_update_rejected "a e" false "b c c/x d" \
 		"cannot process $Q$prefix/c$Q and $Q$prefix/c/x$Q at the same time"
 
 '
-- 
2.8.1
Previous: Michael HaggertyNext: Michael Haggerty
Message 4 of 10 in “Improve test coverage of update-ref error messages”
  1. 0/6 Improve test coverage of update-ref error messagesMichael Haggerty, Jun 10, 2016
  2. 1/6 t1404: rename file to t1404-update-ref-errors.shMichael Haggerty, Jun 10, 2016
  3. 4/6 t1404: add more tests of update-ref error handlingMichael Haggerty, Jun 10, 2016
  4. 2/6 t1404: remove "prefix" argument to test_update_rejectedMichael Haggerty, Jun 10, 2016
  5. 3/6 t1404: document function test_update_rejectedMichael Haggerty, Jun 10, 2016
  6. 6/6 lock_ref_for_update(): avoid a symref resolutionMichael Haggerty, Jun 10, 2016
  7. 5/6 lock_ref_for_update(): make error handling more uniformMichael Haggerty, Jun 10, 2016
  8. David TurnerJun 10, 2016
  9. Michael HaggertyJun 13, 2016
  10. Michael HaggertyJun 13, 2016

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.