From 7ea325c205545bdb01554b51207130e120b9b0f5 Mon Sep 17 00:00:00 2001 From: Bertram Felgenhauer Date: Sat, 8 Nov 2008 20:32:47 +0100 Subject: [PATCH] Find git executable at run time (This is a gross hack and should be rewritten. NixOS and other people who installed git to a prefix different than /usr/ need it.) --- src/Git/Base.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Git/Base.hs b/src/Git/Base.hs index 0198475..a6f3d5e 100644 --- a/src/Git/Base.hs +++ b/src/Git/Base.hs @@ -41,9 +41,11 @@ import Control.Monad.Trans (MonadIO, liftIO) import Control.Monad (MonadPlus, when) import System.Exit (exitFailure, ExitCode (..)) import System.IO (Handle, hPutStr, hClose, hPutStrLn, stderr) +import System.IO.Unsafe (unsafePerformIO) import System.Process (ProcessHandle, runProcess, waitForProcess) import System.Posix (createPipe, setFdOption, fdToHandle, FdOption (..)) import System.FilePath ((), FilePath) +import System.Directory (findExecutable) import Darcs.SlurpDirectory (Slurpy) import Darcs.Patch.FileName (FileName, fn2fp) @@ -51,7 +53,11 @@ import qualified Data.ByteString as B -- | path to git executable gitBinary :: FilePath -gitBinary = "/usr/bin/git" +gitBinary = unsafePerformIO $ do -- FIXME unsafePerformIO, this can be done better + e <- findExecutable "git" + case e of + Just ex -> return ex + Nothing -> fail "git executable not found in PATH" -- | file that maps marks to git commits (created by git-fast-import) marksFile :: FilePath -- 2.11.4.GIT