summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-09-15 15:27:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-09-15 15:28:58 -0400
commita0d3a343b52fba63df523d49849b43217ce744ab (patch)
tree3bd2e0cef5a91a5fdf6183ba3869c77ac6b68eaa /Command
parent7b90cb72fc7d86a8f99d839378fba1ef1c86ff4a (diff)
copy --auto
Only does copy when numcopies is not yet satisfied.
Diffstat (limited to 'Command')
-rw-r--r--Command/Copy.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/Command/Copy.hs b/Command/Copy.hs
index 7d40f438d..125e0bb9f 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -9,11 +9,20 @@ module Command.Copy where
import Command
import qualified Command.Move
+import Utility
command :: [Command]
command = [repoCommand "copy" paramPaths seek
"copy content of files to/from another repository"]
--- A copy is just a move that does not delete the source file.
seek :: [CommandSeek]
-seek = [withFilesInGit $ Command.Move.start False]
+seek = [withNumCopies start]
+
+-- A copy is just a move that does not delete the source file.
+-- However, --auto mode avoids unnecessary copies.
+start :: CommandStartAttrFile
+start (file, attr) = isAnnexed file $ \(key, _) ->
+ autoCopies key (<) numcopies $
+ Command.Move.start False file
+ where
+ numcopies = readMaybe attr