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.)

This commit is contained in:
Joey Hess 2014-01-14 15:36:33 -04:00
parent 188f0bd58d
commit d07f2d7865
7 changed files with 31 additions and 11 deletions

View file

@ -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' }