From 7e7428f173ba1b72b4de69fd482f44161ee84420 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 21 Jun 2011 16:08:09 -0400 Subject: refactor --- GitUnionMerge.hs | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'GitUnionMerge.hs') diff --git a/GitUnionMerge.hs b/GitUnionMerge.hs index dde4b7a04..8aa04f53a 100644 --- a/GitUnionMerge.hs +++ b/GitUnionMerge.hs @@ -12,7 +12,6 @@ module GitUnionMerge ( import System.FilePath import System.Directory import System.Cmd.Utils -import System.Posix.Env (setEnv, unsetEnv) import Control.Monad (when) import Data.List import Data.Maybe @@ -21,27 +20,12 @@ import Data.String.Utils import qualified GitRepo as Git import Utility +{- Performs a union merge. Should be run with a temporary index file + - configured by Git.withIndex. -} unionMerge :: Git.Repo -> String -> String -> String -> IO () unionMerge g aref bref newref = do - setup g stage g aref bref commit g aref bref newref - cleanup g - -tmpIndex :: Git.Repo -> FilePath -tmpIndex g = Git.workTree g Git.gitDir g "index.git-union-merge" - -{- Configures git to use a temporary index file. -} -setup :: Git.Repo -> IO () -setup g = do - cleanup g -- idempotency - setEnv "GIT_INDEX_FILE" (tmpIndex g) True - -cleanup :: Git.Repo -> IO () -cleanup g = do - unsetEnv "GIT_INDEX_FILE" - e' <- doesFileExist (tmpIndex g) - when e' $ removeFile (tmpIndex g) {- Stages the content of both refs into the index. -} stage :: Git.Repo -> String -> String -> IO () @@ -89,7 +73,7 @@ stage g aref bref = do unionmerge content return $ Just $ ls_tree_line sha file -{- Commits the index into the specified branch. -} +{- Commits the index into the specified branch, as a merge commit. -} commit :: Git.Repo -> String -> String -> String -> IO () commit g aref bref newref = do tree <- getSha "write-tree" $ -- cgit v1.2.3