diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-11-11 15:01:13 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-11-11 15:01:13 -0400 |
commit | 962e279e17c1f3cf3be49ffdfb5e7310711a220c (patch) | |
tree | d9953d9e57dea51c24ccaf4d7e64731010546f4f /Git/Index.hs | |
parent | 7d7f93302c72cbe1a16598b0c90a49c10aaf3669 (diff) | |
download | git-repair-962e279e17c1f3cf3be49ffdfb5e7310711a220c.tar.gz |
merge from git-annex
Diffstat (limited to 'Git/Index.hs')
-rw-r--r-- | Git/Index.hs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Git/Index.hs b/Git/Index.hs index 551fd98..85ea480 100644 --- a/Git/Index.hs +++ b/Git/Index.hs @@ -14,6 +14,20 @@ import Utility.Env indexEnv :: String indexEnv = "GIT_INDEX_FILE" +{- Gets value to set GIT_INDEX_FILE to. Input should be absolute path, + - or relative to the CWD. + - + - When relative, GIT_INDEX_FILE is interpreted by git as being + - relative to the top of the work tree of the git repository, + - not to the CWD. Worse, other environment variables (GIT_WORK_TREE) + - or git options (--work-tree) or configuration (core.worktree) + - can change what the relative path is interpreted relative to. + - + - So, an absolute path is the only safe option for this to return. + -} +indexEnvVal :: FilePath -> IO String +indexEnvVal = absPath + {- Forces git to use the specified index file. - - Returns an action that will reset back to the default @@ -21,10 +35,11 @@ indexEnv = "GIT_INDEX_FILE" - - Warning: Not thread safe. -} -override :: FilePath -> IO (IO ()) -override index = do +override :: FilePath -> Repo -> IO (IO ()) +override index _r = do res <- getEnv var - setEnv var index True + val <- indexEnvVal index + setEnv var val True return $ reset res where var = "GIT_INDEX_FILE" |