diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-16 19:57:56 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-16 19:57:56 -0400 |
commit | c69e747d383d308d0cf65d88dc1c3be139d056a9 (patch) | |
tree | f035189a3438fcc7e8826cab31f0c4c48aa205a5 /Core.hs | |
parent | be5b1defeb2f3b5499fd3c002fcdba5b5e9d15f5 (diff) |
refactor
Diffstat (limited to 'Core.hs')
-rw-r--r-- | Core.hs | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -2,6 +2,7 @@ module Core where +import Maybe import System.IO import System.Directory import Control.Monad.State (liftIO) @@ -61,4 +62,22 @@ inAnnex key = do g <- Annex.gitRepo liftIO $ doesFileExist $ annexLocation g key -{- -} +{- Adds, optionally also commits a file to git. + - + - All changes to the git repository should go through this function. + - + - This is careful to not rely on the index. It may have staged changes, + - so only use operations that avoid committing such changes. + -} +gitAdd :: FilePath -> Maybe String -> Annex () +gitAdd file commitmessage = do + nocommit <- Annex.flagIsSet NoCommit + if (nocommit) + then Annex.flagChange NeedCommit True + else do + g <- Annex.gitRepo + liftIO $ Git.run g ["add", file] + if (isJust commitmessage) + then liftIO $ Git.run g ["commit", "-m", + (fromJust commitmessage), file] + else return () |