diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-03 14:33:35 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-03 14:33:35 -0400 |
commit | c74f39843bd07fa86cfa2b1261912013caa05f55 (patch) | |
tree | 3e7b9da0aac366371f49e2c422587db439fb5059 /Command | |
parent | c5412ca7fed26dcc294c5873a07a28f174b255ce (diff) | |
parent | 0064fc0beb98e7254dc026b614bad2e5518ea5dc (diff) |
Merge branch 'master' of ssh://git-annex.branchable.com
Conflicts:
doc/tips/using_Amazon_S3.mdwn
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Import.hs | 39 | ||||
-rw-r--r-- | Command/Lock.hs | 6 |
2 files changed, 40 insertions, 5 deletions
diff --git a/Command/Import.hs b/Command/Import.hs new file mode 100644 index 000000000..e27a421f2 --- /dev/null +++ b/Command/Import.hs @@ -0,0 +1,39 @@ +{- git-annex command + - + - Copyright 2012 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.Import where + +import Common.Annex +import Command +import qualified Annex +import qualified Command.Add + +def :: [Command] +def = [command "import" paramPaths seek "move and add files from outside git working copy"] + +seek :: [CommandSeek] +seek = [withPathContents start] + +start :: (FilePath, FilePath) -> CommandStart +start (srcfile, destfile) = notBareRepo $ + ifM (liftIO $ isRegularFile <$> getSymbolicLinkStatus srcfile) + ( do + showStart "import" destfile + next $ perform srcfile destfile + , stop + ) + +perform :: FilePath -> FilePath -> CommandPerform +perform srcfile destfile = do + whenM (liftIO $ doesFileExist destfile) $ + unlessM (Annex.getState Annex.force) $ + error $ "not overwriting existing " ++ destfile ++ + " (use --force to override)" + + liftIO $ createDirectoryIfMissing True (parentDir destfile) + liftIO $ moveFile srcfile destfile + Command.Add.perform destfile diff --git a/Command/Lock.hs b/Command/Lock.hs index b8aedb252..ab97b14bc 100644 --- a/Command/Lock.hs +++ b/Command/Lock.hs @@ -24,9 +24,5 @@ start file = do perform :: FilePath -> CommandPerform perform file = do - liftIO $ removeFile file - -- Checkout from HEAD to get rid of any changes that might be - -- staged in the index, and get back to the previous symlink to - -- the content. - Annex.Queue.add "checkout" [Param "HEAD", Param "--"] [file] + Annex.Queue.add "checkout" [Param "--"] [file] next $ return True -- no cleanup needed |