diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-14 12:36:40 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-14 12:36:40 -0400 |
commit | 282d9853682f457cc6dc8b095b230bd892f0a5f3 (patch) | |
tree | 7a5af024e72e45ab85652adeea1853051b177449 /Commands.hs | |
parent | 0f12bd16d829432f7b1c2efbba386262ed36fc27 (diff) |
default command
Diffstat (limited to 'Commands.hs')
-rw-r--r-- | Commands.hs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Commands.hs b/Commands.hs index be61c7c64..b4f57d6fe 100644 --- a/Commands.hs +++ b/Commands.hs @@ -1,7 +1,8 @@ {- git-annex subcommands -} module Commands ( - annexCmd, + defaultCmd, + addCmd, unannexCmd, getCmd, wantCmd, @@ -25,10 +26,19 @@ import UUID import LocationLog import Types +{- Default mode is to annex a file if it is not already, and otherwise + - get its content. -} +defaultCmd :: FilePath -> Annex () +defaultCmd file = do + r <- liftIO $ Backend.lookupFile file + case (r) of + Just v -> getCmd file + Nothing -> addCmd file + {- 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. -} -annexCmd :: FilePath -> Annex () -annexCmd file = inBackend file err $ do +addCmd :: FilePath -> Annex () +addCmd file = inBackend file err $ do liftIO $ checkLegal file stored <- Backend.storeFile file g <- Annex.gitRepo @@ -63,7 +73,7 @@ annexCmd file = inBackend file err $ do subdirs = (length $ split "/" file) - 1 -{- Inverse of annexCmd. -} +{- Inverse of addCmd. -} unannexCmd :: FilePath -> Annex () unannexCmd file = notinBackend file err $ \(key, backend) -> do Backend.dropFile backend key |