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.
This commit is contained in:
parent
bb4f31a0ee
commit
eb6cb1b87f
10 changed files with 79 additions and 44 deletions
|
@ -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 }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue