work around broken getEnvironment on Android in the most important place: git annex init

This resulted in a lot of user complains that git annex init had git
telling them they needed to run git config --global user.email .. which
didn't work because even HOME was not passed into git.
This commit is contained in:
Joey Hess 2013-02-22 14:47:29 -04:00
parent 4d4c7c31d7
commit faa9d3c22b
2 changed files with 15 additions and 1 deletions

View file

@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE CPP #-}
module Annex.Branch (
fullname,
name,
@ -22,7 +24,7 @@ module Annex.Branch (
) where
import qualified Data.ByteString.Lazy.Char8 as L
import System.Environment
import System.Posix.Env
import Common.Annex
import Annex.BranchState
@ -285,7 +287,17 @@ withIndex' :: Bool -> Annex a -> Annex a
withIndex' bootstrapping a = do
f <- fromRepo gitAnnexIndex
g <- gitRepo
#ifdef WITH_ANDROID
{- Work around for weird getEnvironment breakage on Android. See
- https://github.com/neurocyte/ghc-android/issues/7
- Instead, use getEnv to get some key environment variables that
- git expects to have. -}
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
#else
e <- liftIO getEnvironment
#endif
let g' = g { gitEnv = Just $ ("GIT_INDEX_FILE", f):e }
Annex.changeState $ \s -> s { Annex.repo = g' }

View file

@ -33,3 +33,5 @@ file modes, etc.
* Make git stop complaining that "warning: no threads uspport, ignoring --threads"
* git does not support http remotes. To fix, need to port libcurl and
allow git to link to it.
* getEnvironment is broken on Android <https://github.com/neurocyte/ghc-android/issues/7>
and a few places use it.