experimentally, removing all actual git committing
Idea is the user will commit when ready, just stage everything.
This commit is contained in:
parent
939a6f860e
commit
4b1086cc7d
4 changed files with 9 additions and 43 deletions
|
@ -11,8 +11,7 @@ import Data.String.Utils
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
|
|
||||||
-- command-line flags
|
-- command-line flags
|
||||||
data Flag = Force | NoCommit | NeedCommit
|
data Flag = Force deriving (Eq, Read, Show)
|
||||||
deriving (Eq, Read, Show)
|
|
||||||
|
|
||||||
-- git-annex's runtime state type doesn't really belong here,
|
-- 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.
|
-- but it uses Backend, so has to be here to avoid a depends loop.
|
||||||
|
|
14
Commands.hs
14
Commands.hs
|
@ -49,7 +49,6 @@ cmds = [
|
||||||
|
|
||||||
options = [
|
options = [
|
||||||
Option ['f'] ["force"] (NoArg Force) "allow actions that may loose annexed data"
|
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) ++ "] ..."
|
header = "Usage: git-annex [" ++ (join "|" $ map cmdname cmds) ++ "] ..."
|
||||||
|
@ -123,7 +122,7 @@ addCmd file = inBackend file $ do
|
||||||
liftIO $ renameFile file dest
|
liftIO $ renameFile file dest
|
||||||
link <- calcGitLink file key
|
link <- calcGitLink file key
|
||||||
liftIO $ createSymbolicLink link file
|
liftIO $ createSymbolicLink link file
|
||||||
gitAdd file $ "git-annex annexed " ++ file
|
liftIO $ Git.run g ["add", file]
|
||||||
showEndOk
|
showEndOk
|
||||||
|
|
||||||
{- Undo addCmd. -}
|
{- Undo addCmd. -}
|
||||||
|
@ -138,14 +137,8 @@ unannexCmd file = notinBackend file $ \(key, backend) -> do
|
||||||
moveout g src
|
moveout g src
|
||||||
where
|
where
|
||||||
moveout g src = do
|
moveout g src = do
|
||||||
nocommit <- Annex.flagIsSet NoCommit
|
|
||||||
liftIO $ removeFile file
|
liftIO $ removeFile file
|
||||||
liftIO $ Git.run g ["rm", "--quiet", 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;
|
-- git rm deletes empty directories;
|
||||||
-- put them back
|
-- put them back
|
||||||
liftIO $ createDirectoryIfMissing True (parentDir file)
|
liftIO $ createDirectoryIfMissing True (parentDir file)
|
||||||
|
@ -212,7 +205,8 @@ fixCmd file = notinBackend file $ \(key, backend) -> do
|
||||||
liftIO $ createDirectoryIfMissing True (parentDir file)
|
liftIO $ createDirectoryIfMissing True (parentDir file)
|
||||||
liftIO $ removeFile file
|
liftIO $ removeFile file
|
||||||
liftIO $ createSymbolicLink link file
|
liftIO $ createSymbolicLink link file
|
||||||
gitAdd file $ "git-annex fix " ++ file
|
g <- Annex.gitRepo
|
||||||
|
liftIO $ Git.run g ["add", file]
|
||||||
showEndOk
|
showEndOk
|
||||||
|
|
||||||
{- Stores description for the repository. -}
|
{- Stores description for the repository. -}
|
||||||
|
@ -227,7 +221,7 @@ initCmd description = do
|
||||||
u <- getUUID g
|
u <- getUUID g
|
||||||
describeUUID u description
|
describeUUID u description
|
||||||
log <- uuidLog
|
log <- uuidLog
|
||||||
gitAdd log $ "description for UUID " ++ (show u)
|
liftIO $ Git.run g ["add", log]
|
||||||
liftIO $ putStrLn "description set"
|
liftIO $ putStrLn "description set"
|
||||||
|
|
||||||
-- helpers
|
-- helpers
|
||||||
|
|
29
Core.hs
29
Core.hs
|
@ -30,15 +30,7 @@ shutdown :: Annex ()
|
||||||
shutdown = do
|
shutdown = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
|
|
||||||
-- handle pending commits
|
liftIO $ Git.run g ["add", gitStateDir g]
|
||||||
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 ()
|
|
||||||
|
|
||||||
-- clean up any files left in the temp directory
|
-- clean up any files left in the temp directory
|
||||||
let tmp = annexTmpLocation g
|
let tmp = annexTmpLocation g
|
||||||
|
@ -77,22 +69,6 @@ inAnnex key = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
liftIO $ doesFileExist $ annexLocation g key
|
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. -}
|
{- Calculates the relative path to use to link a file to a key. -}
|
||||||
calcGitLink :: FilePath -> Key -> Annex FilePath
|
calcGitLink :: FilePath -> Key -> Annex FilePath
|
||||||
calcGitLink file key = do
|
calcGitLink file key = do
|
||||||
|
@ -109,8 +85,7 @@ logStatus :: Key -> LogStatus -> Annex ()
|
||||||
logStatus key status = do
|
logStatus key status = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
u <- getUUID g
|
u <- getUUID g
|
||||||
f <- liftIO $ logChange g key u status
|
liftIO $ logChange g key u status
|
||||||
Annex.flagChange NeedCommit True -- commit all logs at end
|
|
||||||
|
|
||||||
{- Output logging -}
|
{- Output logging -}
|
||||||
showStart :: String -> String -> Annex ()
|
showStart :: String -> String -> Annex ()
|
||||||
|
|
|
@ -80,14 +80,12 @@ instance Read LogLine where
|
||||||
undefined = ret $ LogLine (0) Undefined ""
|
undefined = ret $ LogLine (0) Undefined ""
|
||||||
ret v = [(v, "")]
|
ret v = [(v, "")]
|
||||||
|
|
||||||
{- Log a change in the presence of a key's value in a repository,
|
{- 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 ()
|
||||||
logChange :: Git.Repo -> Key -> UUID -> LogStatus -> IO FilePath
|
|
||||||
logChange repo key uuid status = do
|
logChange repo key uuid status = do
|
||||||
log <- logNow status uuid
|
log <- logNow status uuid
|
||||||
ls <- readLog logfile
|
ls <- readLog logfile
|
||||||
writeLog logfile (compactLog $ log:ls)
|
writeLog logfile (compactLog $ log:ls)
|
||||||
return logfile
|
|
||||||
where
|
where
|
||||||
logfile = logFile repo key
|
logfile = logFile repo key
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue