diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-16 00:02:14 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-16 00:08:39 -0400 |
commit | 7129c1f89e5ff5e5334bb98cab81988c065d4ec2 (patch) | |
tree | 9168a5f55e8d120fb937b11aee08e52d457e9c3a /Git/Config.hs | |
parent | 5fb6e3b804dccf5b727100eb139e289ad6bc0770 (diff) |
A relative core.worktree is relative to the gitdir.
Now that this is handled correctly, git-annex can be used in git submodules.
Also, fixed infelicity where Git.CurrentRepo and Git.Config.updateLocation
were both dealing with core.worktree. Now updateLocation handles it for
Local as well as for LocalUnknown repos.
Diffstat (limited to 'Git/Config.hs')
-rw-r--r-- | Git/Config.hs | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/Git/Config.hs b/Git/Config.hs index 500c8aa0f..cc9b27b69 100644 --- a/Git/Config.hs +++ b/Git/Config.hs @@ -93,7 +93,7 @@ hRead repo h = do store :: String -> Repo -> IO Repo store s repo = do let c = parse s - let repo' = updateLocation $ repo + repo' <- updateLocation $ repo { config = (M.map Prelude.head c) `M.union` config repo , fullconfig = M.unionWith (++) c (fullconfig repo) } @@ -106,16 +106,22 @@ store s repo = do - known. Once the config is read, this can be fixed up to a Local repo, - based on the core.bare and core.worktree settings. -} -updateLocation :: Repo -> Repo +updateLocation :: Repo -> IO Repo updateLocation r@(Repo { location = LocalUnknown d }) - | isBare r = newloc $ Local d Nothing - | otherwise = newloc $ Local (d </> ".git") (Just d) - where - newloc l = r { location = getworktree l } - getworktree l = case workTree r of - Nothing -> l - wt -> l { worktree = wt } -updateLocation r = r + | isBare r = updateLocation' r $ Local d Nothing + | otherwise = updateLocation' r $ Local (d </> ".git") (Just d) +updateLocation r@(Repo { location = l@(Local {}) }) = updateLocation' r l +updateLocation r = return r + +updateLocation' :: Repo -> RepoLocation -> IO Repo +updateLocation' r l = do + l' <- case getMaybe "core.worktree" r of + Nothing -> return l + Just d -> do + {- core.worktree is relative to the gitdir -} + top <- absPath $ gitdir l + return $ l { worktree = Just $ absPathFrom top d } + return $ r { location = l' } {- Parses git config --list or git config --null --list output into a - config map. -} @@ -142,6 +148,3 @@ isTrue s isBare :: Repo -> Bool isBare r = fromMaybe False $ isTrue =<< getMaybe "core.bare" r - -workTree :: Repo -> Maybe FilePath -workTree = getMaybe "core.worktree" |