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

[PATCH 1/2] t1401: generalize reference locking

From
Justin Tobler via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 10, 2024, 18:52 UTC
Message-ID
<cb78b549e5e826ffef39c55bd726164e6b7bb755.1704912750.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1634.git.1704912750.gitgitgadget@gmail.com>
From: Justin Tobler <jltobler@gmail.com>

Some tests set up reference locks by directly creating the lockfile. While this works for the files reference backend, reftable reference locks operate differently and are incompatible with this approach. Refactor the test to use git-update-ref(1) to lock refs instead so that the test does not need to be aware of how the ref backend locks refs.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
 t/t1401-symbolic-ref.sh | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh
index c7745e1bf69..bafe8db24df 100755
--- a/t/t1401-symbolic-ref.sh
+++ b/t/t1401-symbolic-ref.sh
@@ -105,10 +105,30 @@ test_expect_success LONG_REF 'we can parse long symbolic ref' '
 	test_cmp expect actual
 '
 
-test_expect_success 'symbolic-ref reports failure in exit code' '
-	test_when_finished "rm -f .git/HEAD.lock" &&
-	>.git/HEAD.lock &&
-	test_must_fail git symbolic-ref HEAD refs/heads/whatever
+test_expect_success PIPE 'symbolic-ref reports failure in exit code' '
+	mkfifo in out &&
+	(git update-ref --stdin <in >out &) &&
+
+	exec 9>in &&
+	exec 8<out &&
+	test_when_finished "exec 9>&-" &&
+	test_when_finished "exec 8<&-" &&
+
+	echo "start" >&9 &&
+	echo "start: ok" >expected &&
+	read line <&8 &&
+	echo "$line" >actual &&
+	test_cmp expected actual &&
+
+	echo "update HEAD refs/heads/foo" >&9 &&
+
+	echo "prepare" >&9 &&
+	echo "prepare: ok" >expected &&
+	read line <&8 &&
+	echo "$line" >actual &&
+	test_cmp expected actual &&
+
+	test_must_fail git symbolic-ref HEAD refs/heads/bar
 '
 
 test_expect_success 'symbolic-ref writes reflog entry' '
-- 
gitgitgadget
Previous: Justin Tobler via GitGitGadgetNext: Jeff King
Message 2 of 20 in “Generalize reference locking in tests”
  1. 0/2 Generalize reference locking in testsJustin Tobler via GitGitGadget, Jan 10, 2024
  2. 1/2 t1401: generalize reference lockingJustin Tobler via GitGitGadget, Jan 10, 2024
  3. Jeff KingJan 11, 2024
  4. Patrick SteinhardtJan 11, 2024
  5. Jeff KingJan 12, 2024
  6. Patrick SteinhardtJan 12, 2024
  7. Jeff KingJan 12, 2024
  8. Justin ToblerJan 11, 2024
  9. 2/2 t5541: generalize reference lockingJustin Tobler via GitGitGadget, Jan 10, 2024
  10. Jeff KingJan 11, 2024
  11. Junio C HamanoJan 11, 2024
  12. Justin ToblerJan 11, 2024
  13. Junio C HamanoJan 11, 2024
  14. Justin ToblerJan 11, 2024
  15. 0/2 Generalize reference locking in testsJustin Tobler via GitGitGadget, Jan 11, 2024
  16. 1/2 t1401: remove lockfile creationJustin Tobler via GitGitGadget, Jan 11, 2024
  17. 2/2 t5541: remove lockfile creationJustin Tobler via GitGitGadget, Jan 11, 2024
  18. Jeff KingJan 12, 2024
  19. Junio C HamanoJan 12, 2024
  20. Justin ToblerJan 13, 2024

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.