From 5e0adb26375413aaeef7c41dd72e8761e3cc1ada Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 21 Jun 2011 19:11:55 -0400 Subject: fixes make commit commit to the right branch when getting content from the branch, update first --- Branch.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Branch.hs') diff --git a/Branch.hs b/Branch.hs index 9152a0325..82ff5fcad 100644 --- a/Branch.hs +++ b/Branch.hs @@ -7,7 +7,9 @@ module Branch ( update, - change + get, + change, + commit ) where import Control.Monad (unless) @@ -17,8 +19,8 @@ import System.Directory import Data.String.Utils import System.Cmd.Utils -import GitUnionMerge import qualified GitRepo as Git +import qualified GitUnionMerge import qualified Annex import Utility import Types @@ -91,7 +93,7 @@ updateRef ref {- Stages the content of a file into the branch's index. -} change :: FilePath -> String -> Annex () -change file content = update >> do +change file content = do g <- Annex.gitRepo sha <- liftIO $ Git.hashObject g content withIndex $ liftIO $ Git.run g "update-index" @@ -102,17 +104,15 @@ change file content = update >> do commit :: String -> Annex () commit message = withIndex $ do g <- Annex.gitRepo - -- It would be expensive to check if anything needs to be - -- committed, so --allow-empty is used. - liftIO $ Git.run g "commit" - [Param "--allow-empty", Param "-m", Param message] + liftIO $ GitUnionMerge.commit g message branch [] {- Gets the content of a file on the branch, or content staged in the index - if it's newer. Returns an empty string if the file didn't exist yet. -} get :: FilePath -> Annex String -get file = withIndex $ do - g <- Annex.gitRepo - liftIO $ catch (cat g) (const $ return "") +get file = update >> do + withIndex $ do + g <- Annex.gitRepo + liftIO $ catch (cat g) (const $ return "") where -- To avoid stderr from cat-file when file does not exist, -- first run it with -e to check that it exists. -- cgit v1.2.3