ensure that gitdir is absolute

calcGitLink turns out to need it to be absolute, and it normally is,
but not if it's read from a .git file in a submodule, or perhaps from
GIT_DIR.

I should look into dropping this invariant.
This commit is contained in:
Joey Hess 2012-10-16 16:23:50 -04:00
parent 509692847a
commit 4f95cc8ef1
2 changed files with 7 additions and 3 deletions

View file

@ -227,7 +227,8 @@ checkForRepo dir =
catchDefaultIO "" (readFile $ dir </> ".git")
return $ if gitdirprefix `isPrefixOf` c
then Just $ Local
{ gitdir = drop (length gitdirprefix) c
{ gitdir = absPathFrom dir $
drop (length gitdirprefix) c
, worktree = Just dir
}
else Nothing

View file

@ -51,8 +51,11 @@ get = do
configure (Just d) r = do
r' <- Git.Config.read r
-- Let GIT_DIR override the default gitdir.
return $ changelocation r' $
Local { gitdir = d, worktree = worktree (location r') }
absd <- absPath d
return $ changelocation r' $ Local
{ gitdir = absd
, worktree = worktree (location r')
}
addworktree w r = changelocation r $
Local { gitdir = gitdir (location r), worktree = w }
changelocation r l = r { location = l }