experimentally, removing all actual git committing

Idea is the user will commit when ready, just stage everything.
This commit is contained in:
Joey Hess 2010-10-18 01:52:06 -04:00
parent 939a6f860e
commit 4b1086cc7d
4 changed files with 9 additions and 43 deletions

View file

@ -11,8 +11,7 @@ import Data.String.Utils
import qualified GitRepo as Git
-- command-line flags
data Flag = Force | NoCommit | NeedCommit
deriving (Eq, Read, Show)
data Flag = Force deriving (Eq, Read, Show)
-- git-annex's runtime state type doesn't really belong here,
-- but it uses Backend, so has to be here to avoid a depends loop.

View file

@ -49,7 +49,6 @@ cmds = [
options = [
Option ['f'] ["force"] (NoArg Force) "allow actions that may loose annexed data"
, Option ['N'] ["no-commit"] (NoArg NoCommit) "do not stage or commit changes"
]
header = "Usage: git-annex [" ++ (join "|" $ map cmdname cmds) ++ "] ..."
@ -123,7 +122,7 @@ addCmd file = inBackend file $ do
liftIO $ renameFile file dest
link <- calcGitLink file key
liftIO $ createSymbolicLink link file
gitAdd file $ "git-annex annexed " ++ file
liftIO $ Git.run g ["add", file]
showEndOk
{- Undo addCmd. -}
@ -138,14 +137,8 @@ unannexCmd file = notinBackend file $ \(key, backend) -> do
moveout g src
where
moveout g src = do
nocommit <- Annex.flagIsSet NoCommit
liftIO $ removeFile file
liftIO $ Git.run g ["rm", "--quiet", file]
if (not nocommit)
then liftIO $ Git.run g ["commit", "--quiet",
"-m", ("git-annex unannexed " ++ file),
file]
else return ()
-- git rm deletes empty directories;
-- put them back
liftIO $ createDirectoryIfMissing True (parentDir file)
@ -212,7 +205,8 @@ fixCmd file = notinBackend file $ \(key, backend) -> do
liftIO $ createDirectoryIfMissing True (parentDir file)
liftIO $ removeFile file
liftIO $ createSymbolicLink link file
gitAdd file $ "git-annex fix " ++ file
g <- Annex.gitRepo
liftIO $ Git.run g ["add", file]
showEndOk
{- Stores description for the repository. -}
@ -227,7 +221,7 @@ initCmd description = do
u <- getUUID g
describeUUID u description
log <- uuidLog
gitAdd log $ "description for UUID " ++ (show u)
liftIO $ Git.run g ["add", log]
liftIO $ putStrLn "description set"
-- helpers

29
Core.hs
View file

@ -30,15 +30,7 @@ shutdown :: Annex ()
shutdown = do
g <- Annex.gitRepo
-- handle pending commits
nocommit <- Annex.flagIsSet NoCommit
needcommit <- Annex.flagIsSet NeedCommit
if (needcommit && not nocommit)
then do
liftIO $ Git.run g ["add", gitStateDir g]
liftIO $ Git.run g ["commit", "-q", "-m",
"git-annex log update", gitStateDir g]
else return ()
liftIO $ Git.run g ["add", gitStateDir g]
-- clean up any files left in the temp directory
let tmp = annexTmpLocation g
@ -77,22 +69,6 @@ inAnnex key = do
g <- Annex.gitRepo
liftIO $ doesFileExist $ annexLocation g key
{- Adds and commits a file to git.
-
- 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 -> String -> Annex ()
gitAdd file commitmessage = do
nocommit <- Annex.flagIsSet NoCommit
if (nocommit)
then return ()
else do
g <- Annex.gitRepo
liftIO $ Git.run g ["add", file]
liftIO $ Git.run g ["commit", "--quiet",
"-m", commitmessage, file]
{- Calculates the relative path to use to link a file to a key. -}
calcGitLink :: FilePath -> Key -> Annex FilePath
calcGitLink file key = do
@ -109,8 +85,7 @@ logStatus :: Key -> LogStatus -> Annex ()
logStatus key status = do
g <- Annex.gitRepo
u <- getUUID g
f <- liftIO $ logChange g key u status
Annex.flagChange NeedCommit True -- commit all logs at end
liftIO $ logChange g key u status
{- Output logging -}
showStart :: String -> String -> Annex ()

View file

@ -80,14 +80,12 @@ instance Read LogLine where
undefined = ret $ LogLine (0) Undefined ""
ret v = [(v, "")]
{- Log a change in the presence of a key's value in a repository,
- and return the log filename. -}
logChange :: Git.Repo -> Key -> UUID -> LogStatus -> IO FilePath
{- Log a change in the presence of a key's value in a repository. -}
logChange :: Git.Repo -> Key -> UUID -> LogStatus -> IO ()
logChange repo key uuid status = do
log <- logNow status uuid
ls <- readLog logfile
writeLog logfile (compactLog $ log:ls)
return logfile
where
logfile = logFile repo key