extend gitAnnexLink special case for worktrees
authorJoey Hess <joeyh@joeyh.name>
Mon, 14 Jul 2025 18:43:43 +0000 (14:43 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 14 Jul 2025 18:43:43 +0000 (14:43 -0400)
Fix symlinks generated to annexed content when in adjusted unlocked branch in a
linked worktree on a filesystem not supporting symlinks.

Before this fix, the symlink generated by eg git-annex sync in an adjusted
unlocked branch contained ".git/worktrees/". There was a special case
for the similar problem with submodules, so just use it to handle this case as
well. To detect this case, rely on fixupUnusualRepos setting mainWorkTreePath.

Annex/Locations.hs
CHANGELOG

index 8ea90af67c36a123062d47ade537984b8d4c96e7..b2929a28837fdae092bd66986381631f18a0b55d 100644 (file)
@@ -270,10 +270,10 @@ gitAnnexLink file key r config = do
        toInternalGitPath <$> relPathDirToFile (parentDir absfile) loc
   where
        getgitdir currdir
-               {- This special case is for git submodules on filesystems not
-                - supporting symlinks; generate link target that will
-                - work portably. -}
-               | not (coreSymlinks config) && needsSubmoduleFixup r =
+               {- This special case is for git submodules and worktrees
+                - on filesystems not supporting symlinks; generate link
+                - target that will work portably. -}
+               | not (coreSymlinks config) && (needsSubmoduleFixup r || isJust (Git.mainWorkTreePath r)) =
                        absNormPathUnix currdir (Git.repoPath r </> literalOsPath ".git")
                | otherwise = Git.localGitDir r
        absNormPathUnix d p = toInternalGitPath $
index 84e4759738519aa782d426daf3595c466486c5ab..d85abaa2c1293abc1f0b5da5a18637e334bb60d2 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,8 @@ git-annex (10.20250631) UNRELEASED; urgency=medium
     symlinks, that caused annexed file content to be stored in the wrong
     location inside the git directory, and also caused pointer files to not
     get populated.
+  * Fix symlinks generated to annexed content when in adjusted unlocked
+    branch in a linked worktree on a filesystem not supporting symlinks.
 
  -- Joey Hess <id@joeyh.name>  Mon, 07 Jul 2025 15:59:42 -0400