summaryrefslogtreecommitdiff
path: root/Git/Config.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-05-18 18:20:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-05-18 18:20:53 -0400
commiteb6cb1b87f2d7016ddd4386e2a3bb20d8ea3c036 (patch)
tree1f9f35e7ca3db662bd67ec759de90267149319fa /Git/Config.hs
parentbb4f31a0ee496ffb83d31cc56f8827e47605d763 (diff)
Add support for core.worktree, and fix support for GIT_WORK_TREE and GIT_DIR.
The environment needs to override git-config. Changed when git config is read, and avoid rereading it once it's been read. chdir for both worktree settings.
Diffstat (limited to 'Git/Config.hs')
-rw-r--r--Git/Config.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/Git/Config.hs b/Git/Config.hs
index e37b43707..2fa685a11 100644
--- a/Git/Config.hs
+++ b/Git/Config.hs
@@ -27,16 +27,20 @@ getList key repo = M.findWithDefault [] key (fullconfig repo)
getMaybe :: String -> Repo -> Maybe String
getMaybe key repo = M.lookup key (config repo)
-{- Runs git config and populates a repo with its config. -}
+{- Runs git config and populates a repo with its config.
+ - Cannot use pipeRead because it relies on the config having been already
+ - read. Instead, chdir to the repo.
+ -}
read :: Repo -> IO Repo
read repo@(Repo { location = Local { gitdir = d } }) = read' repo d
read repo@(Repo { location = LocalUnknown d }) = read' repo d
read r = assertLocal r $ error "internal"
-{- Cannot use pipeRead because it relies on the config having
- been already read. Instead, chdir to the repo. -}
read' :: Repo -> FilePath -> IO Repo
-read' repo d = bracketCd d $
- pOpen ReadFromPipe "git" ["config", "--null", "--list"] $ hRead repo
+read' repo@(Repo { config = c}) d
+ | c == M.empty = bracketCd d $
+ pOpen ReadFromPipe "git" ["config", "--null", "--list"] $
+ hRead repo
+ | otherwise = return repo -- config already read
{- Reads git config from a handle and populates a repo with it. -}
hRead :: Repo -> Handle -> IO Repo
@@ -55,7 +59,6 @@ store s repo = do
{ config = (M.map Prelude.head c) `M.union` config repo
, fullconfig = M.unionWith (++) c (fullconfig repo)
}
- print repo'
rs <- Git.Construct.fromRemotes repo'
return $ repo' { remotes = rs }