Skip to content

Commit

Permalink
Fix for broken git commits
Browse files Browse the repository at this point in the history
The problem was that by setting the Environment through runProcess, the
current environment gets eradicated. This causes git to bail out. The
fix is simple: query the current environment and append any additional
variables.
  • Loading branch information
Jochen Keil committed Mar 16, 2013
1 parent 8aa4811 commit 0772638
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Data/FileStore/Utils.hs
Expand Up @@ -27,7 +27,8 @@ module Data.FileStore.Utils (
, encodeArg ) where , encodeArg ) where


import Control.Exception (throwIO) import Control.Exception (throwIO)
import Control.Monad (liftM, when, unless) import Control.Applicative ((<$>))
import Control.Monad (liftM, liftM2, when, unless)
import Data.ByteString.Lazy.UTF8 (toString) import Data.ByteString.Lazy.UTF8 (toString)
import Data.Char (isSpace) import Data.Char (isSpace)
import Data.List (intersect, nub, isPrefixOf, isInfixOf) import Data.List (intersect, nub, isPrefixOf, isInfixOf)
Expand All @@ -39,6 +40,7 @@ import System.FilePath ((</>), takeDirectory)
import System.IO (openTempFile, hClose) import System.IO (openTempFile, hClose)
import System.IO.Error (isDoesNotExistError) import System.IO.Error (isDoesNotExistError)
import System.Process (runProcess, waitForProcess) import System.Process (runProcess, waitForProcess)
import System.Environment (getEnvironment)
import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString as S import qualified Data.ByteString as S
import qualified Control.Exception as E import qualified Control.Exception as E
Expand Down Expand Up @@ -68,7 +70,8 @@ runShellCommand workingDir environment command optionList = do
tempPath <- E.catch getTemporaryDirectory (\(_ :: E.SomeException) -> return ".") tempPath <- E.catch getTemporaryDirectory (\(_ :: E.SomeException) -> return ".")
(outputPath, hOut) <- openTempFile tempPath "out" (outputPath, hOut) <- openTempFile tempPath "out"
(errorPath, hErr) <- openTempFile tempPath "err" (errorPath, hErr) <- openTempFile tempPath "err"
hProcess <- runProcess (encodeArg command) (map encodeArg optionList) (Just workingDir) environment Nothing (Just hOut) (Just hErr) env <- liftM2 (++) environment . Just <$> getEnvironment
hProcess <- runProcess (encodeArg command) (map encodeArg optionList) (Just workingDir) env Nothing (Just hOut) (Just hErr)
status <- waitForProcess hProcess status <- waitForProcess hProcess
errorOutput <- S.readFile errorPath errorOutput <- S.readFile errorPath
output <- S.readFile outputPath output <- S.readFile outputPath
Expand Down

0 comments on commit 0772638

Please sign in to comment.