deal with .git pointer file in Git.CurrentRepo

This fixes the bug.

Note, it's only done when GIT_DIR is set. When it's not set,
Git.Construct already handled it. This is why it was only noticed with this
git submodule command.

This commit was sponsored by Brett Eisenberg on Patreon.
This commit is contained in:
Joey Hess 2020-10-23 14:56:12 -04:00
parent 893d7b21e8
commit 681313dfd4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 38 additions and 24 deletions

View file

@ -67,15 +67,14 @@ get = do
configure (Just d) _ = do
absd <- absPath d
curr <- getCurrentDirectory
r <- Git.Config.read $ newFrom $
Local
{ gitdir = toRawFilePath absd
, worktree = Just (toRawFilePath curr)
}
loc <- adjustGitDirFile $ Local
{ gitdir = toRawFilePath absd
, worktree = Just (toRawFilePath curr)
}
r <- Git.Config.read $ newFrom loc
return $ if Git.Config.isBare r
then r { location = (location r) { worktree = Nothing } }
else r
configure Nothing Nothing = giveup "Not in a git repository."
addworktree w r = changelocation r $ Local