summaryrefslogtreecommitdiff
path: root/Command/Copy.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-03-25 17:06:14 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-03-25 17:06:14 -0400
commit850241b7fed075c8a0055ae77cb30d6485aaa795 (patch)
treebbae2d577ea7daf136cfb80cdf87e4ce76681f84 /Command/Copy.hs
parent644cd4ca27e410ca567ec0f78acf2517d91d330e (diff)
--auto is no longer a global option; only get, drop, and copy accept it.
Not a behavior change unless you were passing it to a command that ignored it.
Diffstat (limited to 'Command/Copy.hs')
-rw-r--r--Command/Copy.hs22
1 files changed, 14 insertions, 8 deletions
diff --git a/Command/Copy.hs b/Command/Copy.hs
index e5b093c61..1b9b2aac8 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -15,26 +15,32 @@ import Annex.Wanted
import Config.NumCopies
cmd :: [Command]
-cmd = [withOptions Command.Move.moveOptions $ command "copy" paramPaths seek
+cmd = [withOptions copyOptions $ command "copy" paramPaths seek
SectionCommon "copy content of files to/from another repository"]
+copyOptions :: [Option]
+copyOptions = Command.Move.moveOptions ++ [autoOption]
+
seek :: CommandSeek
seek ps = do
to <- getOptionField toOption Remote.byNameWithUUID
from <- getOptionField fromOption Remote.byNameWithUUID
- withKeyOptions
+ auto <- getOptionFlag autoOption
+ withKeyOptions auto
(Command.Move.startKey to from False)
- (withFilesInGit $ whenAnnexed $ start to from)
+ (withFilesInGit $ whenAnnexed $ start auto to from)
ps
{- A copy is just a move that does not delete the source file.
- - However, --auto mode avoids unnecessary copies, and avoids getting or
+ - However, auto mode avoids unnecessary copies, and avoids getting or
- sending non-preferred content. -}
-start :: Maybe Remote -> Maybe Remote -> FilePath -> Key -> CommandStart
-start to from file key = stopUnless shouldCopy $
+start :: Bool -> Maybe Remote -> Maybe Remote -> FilePath -> Key -> CommandStart
+start auto to from file key = stopUnless shouldCopy $
Command.Move.start to from False file key
where
- shouldCopy = checkAuto (check <||> numCopiesCheck file key (<))
- check = case to of
+ shouldCopy
+ | auto = want <||> numCopiesCheck file key (<)
+ | otherwise = return True
+ want = case to of
Nothing -> wantGet False (Just key) (Just file)
Just r -> wantSend False (Just key) (Just file) (Remote.uuid r)