Propigate GIT_DIR and GIT_WORK_TREE environment to external special remotes.
Since git-annex unsets these when started, they have to be explicitly propigated. Also, this makes --git-dir and --work-tree settings be reflected in the environment. The need for this came up in https://github.com/DanielDent/git-annex-remote-rclone/issues/3
This commit is contained in:
parent
36137c444b
commit
6659c7ec0e
4 changed files with 25 additions and 4 deletions
14
Git/Env.hs
14
Git/Env.hs
|
@ -9,12 +9,10 @@
|
|||
|
||||
module Git.Env where
|
||||
|
||||
import Common
|
||||
import Git
|
||||
import Git.Types
|
||||
import Utility.Env
|
||||
#ifdef __ANDROID__
|
||||
import Common
|
||||
#endif
|
||||
|
||||
{- Adjusts the gitEnv of a Repo. Copies the system environment if the repo
|
||||
- does not have any gitEnv yet. -}
|
||||
|
@ -41,6 +39,16 @@ adjustGitEnv g adj = do
|
|||
addGitEnv :: Repo -> String -> String -> IO Repo
|
||||
addGitEnv g var val = adjustGitEnv g (addEntry var val)
|
||||
|
||||
{- Environment variables to use when running a command.
|
||||
- Includes GIT_DIR pointing at the repo, and GIT_WORK_TREE when the repo
|
||||
- is not bare. Also includes anything added to the Repo's gitEnv,
|
||||
- and a copy of the rest of the system environment. -}
|
||||
propGitEnv :: Repo -> IO [(String, String)]
|
||||
propGitEnv g = do
|
||||
g' <- addGitEnv g "GIT_DIR" (localGitDir g)
|
||||
g'' <- maybe (pure g') (addGitEnv g' "GIT_WORK_TREE") (repoWorkTree g)
|
||||
return $ fromMaybe [] (gitEnv g'')
|
||||
|
||||
{- Use with any action that makes a commit to set metadata. -}
|
||||
commitWithMetaData :: CommitMetaData -> CommitMetaData -> (Repo -> IO a) -> Repo -> IO a
|
||||
commitWithMetaData authormetadata committermetadata a g =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue