avoid changing gitdir

This code dates back 10 years to commit
e322826e33. But as far as I can tell,
it was never necessary. Notice that the comment added in that
commit doesn't match the code -- it says it adjusts the Repo when
the filesystem doesn't support symlinks, but it actually only adjusts
the Repo when the filesystem *does* support symlinks.

Testing in a submodule after this change, annex symlinks still point to
.git/annex/objects/.

(Note that gitAnnexLink contains a special case for submodules on filesystem
not supporting symlinks. I have verified that special case still works.
Without that special case, the annex links look like eg
"../.git/modules/foo/annex/objects", and with them, they look like
".git/annex/objects"
This commit is contained in:
Joey Hess 2025-07-14 13:52:13 -04:00
parent addcd389ff
commit 9cdcbedf2d
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -104,7 +104,7 @@ fixupUnusualRepos r@(Repo { location = l@(Local { worktree = Just w, gitdir = d
(replacedotgit >> unsetcoreworktree) (replacedotgit >> unsetcoreworktree)
`catchNonAsync` \e -> hPutStrLn stderr $ `catchNonAsync` \e -> hPutStrLn stderr $
"warning: unable to convert submodule to form that will work with git-annex: " ++ show e "warning: unable to convert submodule to form that will work with git-annex: " ++ show e
return $ r' return $ r
{ config = M.delete "core.worktree" (config r) { config = M.delete "core.worktree" (config r)
} }
| otherwise = ifM (needsGitLinkFixup r) | otherwise = ifM (needsGitLinkFixup r)
@ -114,8 +114,8 @@ fixupUnusualRepos r@(Repo { location = l@(Local { worktree = Just w, gitdir = d
(replacedotgit >> worktreefixup) (replacedotgit >> worktreefixup)
`catchNonAsync` \e -> hPutStrLn stderr $ `catchNonAsync` \e -> hPutStrLn stderr $
"warning: unable to convert .git file to symlink that will work with git-annex: " ++ show e "warning: unable to convert .git file to symlink that will work with git-annex: " ++ show e
setworktreepath r' setworktreepath r
else setworktreepath r' else setworktreepath r
, return r , return r
) )
where where
@ -138,11 +138,11 @@ fixupUnusualRepos r@(Repo { location = l@(Local { worktree = Just w, gitdir = d
fmap toOsPath . headMaybe . lines fmap toOsPath . headMaybe . lines
<$> readFile commondirfile <$> readFile commondirfile
setworktreepath r'' = readcommondirfile >>= \case setworktreepath r' = readcommondirfile >>= \case
Just gd -> return $ r'' Just gd -> return $ r'
{ mainWorkTreePath = Just gd { mainWorkTreePath = Just gd
} }
Nothing -> return r'' Nothing -> return r'
worktreefixup = readcommondirfile >>= \case worktreefixup = readcommondirfile >>= \case
Just gd -> do Just gd -> do
@ -153,13 +153,6 @@ fixupUnusualRepos r@(Repo { location = l@(Local { worktree = Just w, gitdir = d
R.createSymbolicLink (fromOsPath linktarget) $ R.createSymbolicLink (fromOsPath linktarget) $
fromOsPath $ dotgit </> literalOsPath "annex" fromOsPath $ dotgit </> literalOsPath "annex"
Nothing -> return () Nothing -> return ()
-- Repo adjusted, so that symlinks to objects that get checked
-- in will have the usual path, rather than pointing off to the
-- real .git directory.
r'
| coreSymlinks c = r { location = l { gitdir = dotgit } }
| otherwise = r
fixupUnusualRepos r _ = return r fixupUnusualRepos r _ = return r
needsSubmoduleFixup :: Repo -> Bool needsSubmoduleFixup :: Repo -> Bool