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

[PATCH 1/8] t0600: don't create ref outside of refs/

From
Jeff King <peff@peff.net>
Date
Apr 29, 2024, 08:16 UTC
Message-ID
<20240429081652.GA228803@coredump.intra.peff.net>
In-Reply-To
<20240429081512.GA4130242@coredump.intra.peff.net>

We have a test that tries to manipulate the branch refs/heads/referrent, mostly using either the fully qualified refname or git-branch (which implies refs/heads/). However, the call to update-ref uses the unqualified name, meaning we were quietly creating ".git/referrent", which was otherwise unused by the test.

Fix this to specify refs/heads/referrent.

I _think_ it actually doesn't affect the test outcome either way. The point of the test is that expiring reflogs for "the_symref" should not fail when we cannot lock "refs/heads/referrent" that it points to (because we have created a fake .lock file for it). And that is true even if the "referrent" file does not even exist. After all, the process holding the lock could be in the act of creating it.

So I suspect this "update-ref" line could just be dropped entirely. Which you can verify by going back to its origin in 41d796ed5c (refs: on symref reflog expire, lock symref not referrent, 2016-04-07) and removing it. The test fails without the matching code change and passes with it.

But I think it's worth keeping the update-ref call, as it creates a situation which is more likely to match what we'd see in the real world. Even if it does not matter now, it's possible it could in the future.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t0600-reffiles-backend.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t0600-reffiles-backend.sh b/t/t0600-reffiles-backend.sh
index 64214340e7..41db9e30d4 100755
--- a/t/t0600-reffiles-backend.sh
+++ b/t/t0600-reffiles-backend.sh
@@ -343,7 +343,7 @@ test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
 test_expect_success 'reflog expire operates on symref not referrent' '
 	git branch --create-reflog the_symref &&
 	git branch --create-reflog referrent &&
-	git update-ref referrent HEAD &&
+	git update-ref refs/heads/referrent HEAD &&
 	git symbolic-ref refs/heads/the_symref refs/heads/referrent &&
 	test_when_finished "rm -f .git/refs/heads/referrent.lock" &&
 	touch .git/refs/heads/referrent.lock &&
-- 
2.45.0.rc1.416.gbe2a76c799
Previous: Jeff KingNext: Jeff King
Message 2 of 7 in “tightening ref handling outside of refs/”
  1. 0/8 tightening ref handling outside of refs/Jeff King, Apr 29, 2024
  2. 1/8 t0600: don't create ref outside of refs/Jeff King, Apr 29, 2024
  3. Jeff KingApr 29, 2024
  4. Jeff KingApr 29, 2024
  5. Patrick SteinhardtApr 29, 2024
  6. Jeff KingApr 30, 2024
  7. Junio C HamanoApr 29, 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.