summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-22 14:47:29 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-22 14:47:29 -0400
commit4f13f95136ebe184a7e68090aa156ae19b037537 (patch)
tree0ccd2f1777fbc0cd4d21e5b12c982c40f08af01c /Annex
parente23d6af007becc38adb415f94981e8b36daa6fa3 (diff)
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.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Branch.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index 69b68cf7a..95ac49404 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -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' }