aboutsummaryrefslogtreecommitdiff
path: root/Annex/Branch.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-14 15:36:33 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-14 15:36:33 -0400
commite6f32bd11c94221f82fe9acf6ecb74be2fab4a76 (patch)
treef52a5aa501875340c05f34c151fd027036cff83a /Annex/Branch.hs
parent44b6bc589b6e2219cd3a4cf57fd2dd30068b2744 (diff)
Fix a long-standing bug that could cause the wrong index file to be used when committing to the git-annex branch, if GIT_INDEX_FILE is set in the environment. This typically resulted in git-annex branch log files being committed to the master branch and later showing up in the work tree. (These log files can be safely removed.)
Diffstat (limited to 'Annex/Branch.hs')
-rw-r--r--Annex/Branch.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index 658ad731f..5a9522689 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -29,6 +29,7 @@ module Annex.Branch (
import qualified Data.ByteString.Lazy.Char8 as L
import qualified Data.Set as S
import qualified Data.Map as M
+import qualified Data.AssocList as A
import qualified Control.Exception as E
import Common.Annex
@@ -342,10 +343,12 @@ withIndex' bootstrapping a = do
let keyenv = words "USER PATH GIT_EXEC_PATH HOSTNAME HOME"
let getEnvPair k = maybe Nothing (\v -> Just (k, v)) <$> getEnv k
e <- liftIO $ catMaybes <$> forM keyenv getEnvPair
+ let e' = ("GIT_INDEX_FILE", f):e
#else
e <- liftIO getEnvironment
+ let e' = A.addEntry "GIT_INDEX_FILE" f e
#endif
- let g' = g { gitEnv = Just $ ("GIT_INDEX_FILE", f):e }
+ let g' = g { gitEnv = Just e' }
r <- tryAnnex $ do
Annex.changeState $ \s -> s { Annex.repo = g' }