summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-16 19:43:32 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-16 19:43:32 -0400
commitbe5b1defeb2f3b5499fd3c002fcdba5b5e9d15f5 (patch)
tree1c6ea3d755aa0cc3cc41aab4864e21c16a75c778
parentb3e5590fb2995d73d5e69a3954fcb11d9fe98d28 (diff)
add --no-commit option
-rw-r--r--BackendTypes.hs2
-rw-r--r--Commands.hs37
-rw-r--r--Core.hs3
-rw-r--r--TODO3
4 files changed, 32 insertions, 13 deletions
diff --git a/BackendTypes.hs b/BackendTypes.hs
index 49bd1bceb..06ecfb8fe 100644
--- a/BackendTypes.hs
+++ b/BackendTypes.hs
@@ -11,7 +11,7 @@ import Data.String.Utils
import qualified GitRepo as Git
-- command-line flags
-data Flag = Force | NeedCommit
+data Flag = Force | NoCommit | NeedCommit
deriving (Eq, Read, Show)
-- git-annex's runtime state type doesn't really belong here,
diff --git a/Commands.hs b/Commands.hs
index c477a81fd..63ca6b5e4 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -32,7 +32,8 @@ data Command = Command {
}
cmds :: [Command]
-cmds = [ (Command "add" addCmd FilesNotInGit)
+cmds = [
+ (Command "add" addCmd FilesNotInGit)
, (Command "get" getCmd FilesInGit)
, (Command "drop" dropCmd FilesInGit)
, (Command "push" pushCmd RepoName)
@@ -41,6 +42,11 @@ cmds = [ (Command "add" addCmd FilesNotInGit)
, (Command "describe" describeCmd SingleString)
]
+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"
+ ]
+
{- Finds the type of parameters a command wants, from among the passed
- parameter list. -}
findWanted :: CmdWants -> [String] -> Git.Repo -> IO [String]
@@ -75,7 +81,6 @@ parseCmd argv state = do
lookupCmd cmd = filter (\c -> cmd == cmdname c) cmds
header = "Usage: git-annex [" ++
(join "|" $ map cmdname cmds) ++ "] ..."
- options = [ Option ['f'] ["force"] (NoArg Force) "allow actions that may loose annexed data" ]
{- Annexes a file, storing it in a backend, and then moving it into
- the annex directory and setting up the symlink pointing to its content. -}
@@ -89,7 +94,7 @@ addCmd file = inBackend file err $ do
Nothing -> error $ "no backend could store: " ++ file
Just (key, backend) -> do
logStatus key ValuePresent
- liftIO $ setup g key link
+ setup g key link
where
err = error $ "already annexed " ++ file
checkLegal file = do
@@ -106,12 +111,16 @@ addCmd file = inBackend file err $ do
setup g key link = do
let dest = annexLocation g key
let reldest = annexLocationRelative g key
- createDirectoryIfMissing True (parentDir dest)
- renameFile file dest
- createSymbolicLink (link ++ reldest) file
- Git.run g ["add", file]
- Git.run g ["commit", "-m",
- ("git-annex annexed " ++ file), file]
+ liftIO $ createDirectoryIfMissing True (parentDir dest)
+ liftIO $ renameFile file dest
+ liftIO $ createSymbolicLink (link ++ reldest) file
+ nocommit <- Annex.flagIsSet NoCommit
+ if (not nocommit)
+ then do
+ liftIO $ Git.run g ["add", file]
+ liftIO $ Git.run g ["commit", "-m",
+ ("git-annex annexed " ++ file), file]
+ else return ()
{- Inverse of addCmd. -}
unannexCmd :: FilePath -> Annex ()
@@ -192,7 +201,10 @@ describeCmd description = do
u <- getUUID g
describeUUID u description
log <- uuidLog
- liftIO $ Git.run g ["add", log]
+ nocommit <- Annex.flagIsSet NoCommit
+ if (not nocommit)
+ then liftIO $ Git.run g ["add", log]
+ else return ()
Annex.flagChange NeedCommit True
liftIO $ putStrLn "description set"
@@ -202,7 +214,10 @@ logStatus key status = do
g <- Annex.gitRepo
u <- getUUID g
f <- liftIO $ logChange g key u status
- liftIO $ Git.run g ["add", f]
+ nocommit <- Annex.flagIsSet NoCommit
+ if (not nocommit)
+ then liftIO $ Git.run g ["add", f]
+ else return ()
Annex.flagChange NeedCommit True
inBackend file yes no = do
diff --git a/Core.hs b/Core.hs
index fcbce4163..6e48068f9 100644
--- a/Core.hs
+++ b/Core.hs
@@ -24,8 +24,9 @@ startup flags = do
shutdown :: Annex ()
shutdown = do
g <- Annex.gitRepo
+ nocommit <- Annex.flagIsSet NoCommit
needcommit <- Annex.flagIsSet NeedCommit
- if (needcommit)
+ if (needcommit && not nocommit)
then liftIO $ Git.run g ["commit", "-q", "-m",
"git-annex log update", gitStateDir g]
else return ()
diff --git a/TODO b/TODO
index cd94f03bc..fedcce6dd 100644
--- a/TODO
+++ b/TODO
@@ -5,6 +5,9 @@
* how to handle git mv file?
+* how to handle git rm file? (should try to drop keys that have no
+ referring file, if it seems safe..)
+
* Support for remote git repositories (ssh:// specifically can be made to
work, although the other end probably needs to have git-annex installed..)