diff mbox series

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

Message ID 20240429081652.GA228803@coredump.intra.peff.net (mailing list archive)
State New, archived
Headers show
Series tightening ref handling outside of refs/ | expand

Commit Message

Jeff King April 29, 2024, 8:16 a.m. UTC
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 mbox series

Patch

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 &&