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

[PATCH 1/4] t5510: ensure that the packed-refs file needs locking

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 14, 2023, 08:58 UTC
Message-ID
<4be411fa413fda675314b8507d41f4141a1f97ac.1699951815.git.ps@pks.im>
In-Reply-To
<cover.1699951815.git.ps@pks.im>

One of the tests in t5510 asserts that a `git fetch --prune` detects failures to prune branches. This is done by locking the packed-refs file, which would then later lead to a locking issue when Git tries to rewrite the file to prune the branches from it.

Interestingly though, we do not pack the about-to-be-pruned branch into the packed-refs file, so it never even contained that branch in the first place. While this is good enough right now because the pruning will always lock the file regardless of whether it contains the branch or not, this is a mere implementation detail. In fact, we're about to rewrite branch deletions to make use of the ref transaction interface, which knows to skip rewrites of the packed-refs file in the case where it does not contain the branches in the first place, and this will break the test.

Prepare the test for that change by packing the refs before trying to prune them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t5510-fetch.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index dcadd56d3a..79592a3b0a 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -169,6 +169,7 @@ test_expect_success REFFILES 'fetch --prune fails to delete branches' '
 	git clone . prune-fail &&
 	cd prune-fail &&
 	git update-ref refs/remotes/origin/extrabranch main &&
+	git pack-refs --all &&
 	: this will prevent --prune from locking packed-refs for deleting refs, but adding loose refs still succeeds  &&
 	>.git/packed-refs.new &&
 
-- 
2.42.0
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 2 of 5 in “refs: remove virtual `delete_refs()` function”
  1. 0/4 refs: remove virtual `delete_refs()` functionPatrick Steinhardt, Nov 14, 2023
  2. 1/4 t5510: ensure that the packed-refs file needs lockingPatrick Steinhardt, Nov 14, 2023
  3. 2/4 refs/files: use transactions to delete referencesPatrick Steinhardt, Nov 14, 2023
  4. 3/4 refs: deduplicate code to delete referencesPatrick Steinhardt, Nov 14, 2023
  5. 4/4 refs: remove `delete_refs` callback from backendsPatrick Steinhardt, Nov 14, 2023

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.