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

[PATCH v2 0/1] [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refs

From
shejialuo <shejialuo@gmail.com>
Date
Jun 2, 2025, 13:26 UTC
Message-ID
<aD2mhOlwl1LSYnpe@ArchLinux>
In-Reply-To
<aDp55upE6AhYunz7@ArchLinux>
Hi All:
This version updates the following things:
1. Update the commit message to incorporate the commit message that
introduces the BUG to better explain.
2. Update the shell script to avoid hardcode gitdir path.
3. Change "rm -rf" to be "rmdir", which would be safer because we should
delete an empty directory, which has a better semantics.

Thanks, Jialuo

shejialuo (1):
  fsck: ignore missing "refs" directory for linked worktrees
 refs/files-backend.c     |  3 +++
 t/t0602-reffiles-fsck.sh | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)
Range-diff against v1:
1:  bfde11adb6 ! 1:  d949a8a646 fsck: ignore missing "refs" directory for linked worktrees
    @@ Metadata
      ## Commit message ##
         fsck: ignore missing "refs" directory for linked worktrees
     
    -    It is reported that "git refs verify" would fail when encountering
    -    worktrees created on Git v2.43.0 or older versions. These versions
    -    don't automatically create the "refs" directory, causing the error:
    +    "git refs verify" doesn't work if there are worktrees created on Git
    +    v2.43.0 or older versions. These versions don't automatically create the
    +    "refs" directory, causing the error:
     
             error: cannot open directory .git/worktrees/<worktree name>/refs:
             No such file or directory
     
         Since 8f4c00de95 (builtin/worktree: create refdb via ref backend,
         2024-01-08), we automatically create the "refs" directory for new
    -    worktrees. However, the fsck code incorrectly assumes all linked
    -    worktrees have this directory, thus introducing compatibility issue.
    +    worktrees. And in 7c78d819e6 (ref: support multiple worktrees check for
    +    refs, 2024-11-20), we assume that all linked worktrees have this
    +    directory and would wrongly report an error to the user, thus
    +    introducing compatibility issue.
     
         Check for ENOENT errno before reporting directory access errors for
         linked worktrees to maintain backward compatibility.
    @@ t/t0602-reffiles-fsck.sh: test_expect_success 'ref name check should be adapted
     +	(
     +		cd repo &&
     +		test_commit initial &&
    -+
     +		git worktree add --detach ./worktree &&
    ++
    ++		cd worktree &&
    ++		worktree_refdir="$(git rev-parse --git-dir)/refs" &&
     +		# Simulate old directory layout
    -+		rm -rf ./git/worktrees/worktree/refs &&
    ++		rmdir "$worktree_refdir" &&
     +		git refs verify 2>err &&
     +		test_must_be_empty err
     +	)
-- 
2.49.0
Previous: shejialuoNext: shejialuo
Message 15 of 21 in “[BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refs”
  1. kristofferhaugsbakk@fastmail.comMay 30, 2025
  2. Eric SunshineMay 30, 2025
  3. shejialuoMay 31, 2025
  4. Kristoffer HaugsbakkMay 31, 2025
  5. fsck: ignore missing "refs" directory for linked worktreesshejialuo, May 31, 2025
  6. Kristoffer HaugsbakkMay 31, 2025
  7. Junio C HamanoJun 2, 2025
  8. shejialuoJun 2, 2025
  9. Phillip WoodJun 2, 2025
  10. Patrick SteinhardtJun 2, 2025
  11. phillip.wood123@gmail.comJun 2, 2025
  12. Junio C HamanoJun 2, 2025
  13. shejialuoJun 2, 2025
  14. shejialuoJun 2, 2025
  15. 0/1 [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refsshejialuo, Jun 2, 2025
  16. 1/1 fsck: ignore missing "refs" directory for linked worktreesshejialuo, Jun 2, 2025
  17. Kristoffer HaugsbakkJun 2, 2025
  18. shejialuoJun 2, 2025
  19. 0/1 [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refsshejialuo, Jun 2, 2025
  20. 1/1 fsck: ignore missing "refs" directory for linked worktreesshejialuo, Jun 2, 2025
  21. Kristoffer HaugsbakkJun 2, 2025

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.