summaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-06-21 16:08:09 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-06-21 16:08:09 -0400
commit7e7428f173ba1b72b4de69fd482f44161ee84420 (patch)
tree7db187ad39b67905fb0de179c74fcd48ff603663 /GitRepo.hs
parenta5e6802b5b6f9354e065936998d9882e8ceecb5b (diff)
refactor
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index 9f4a38a5f..11511f77d 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -58,6 +58,7 @@ module GitRepo (
typeChangedStagedFiles,
repoAbsPath,
reap,
+ withIndex,
prop_idempotent_deencode
) where
@@ -82,6 +83,7 @@ import Codec.Binary.UTF8.String (encode)
import Text.Printf
import Data.List (isInfixOf, isPrefixOf, isSuffixOf)
import System.Exit
+import System.Posix.Env (setEnv, unsetEnv)
import Utility
@@ -379,6 +381,14 @@ reap = do
r <- catch (getAnyProcessStatus False True) (\_ -> return Nothing)
maybe (return ()) (const reap) r
+{- Runs an action using a specified index file. -}
+withIndex :: FilePath -> IO a -> IO a
+withIndex index a = do
+ setEnv "GIT_INDEX_FILE" index True
+ r <- a
+ unsetEnv "GIT_INDEX_FILE"
+ return r
+
{- Scans for files that are checked into git at the specified locations. -}
inRepo :: Repo -> [FilePath] -> IO [FilePath]
inRepo repo l = pipeNullSplit repo $