aboutsummaryrefslogtreecommitdiff
path: root/Command/FromKey.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-03-15 13:51:58 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-03-15 13:51:58 -0400
commit5f7979ffe85e036451bb869e29ca161ad3aa0272 (patch)
treeb32ded92fe379a2d8155534e43a5a96194e2e277 /Command/FromKey.hs
parent97822392b77b6d6327c1d8f78044e57025032010 (diff)
fromkey --force: Skip test that the key has its content in the annex.
Diffstat (limited to 'Command/FromKey.hs')
-rw-r--r--Command/FromKey.hs18
1 files changed, 11 insertions, 7 deletions
diff --git a/Command/FromKey.hs b/Command/FromKey.hs
index d9ebe6b4c..7176d97a5 100644
--- a/Command/FromKey.hs
+++ b/Command/FromKey.hs
@@ -12,6 +12,7 @@ import Command
import qualified Annex.Queue
import Annex.Content
import Types.Key
+import qualified Annex
cmd :: [Command]
cmd = [notDirect $ notBareRepo $
@@ -19,17 +20,20 @@ cmd = [notDirect $ notBareRepo $
SectionPlumbing "adds a file using a specific key"]
seek :: CommandSeek
-seek = withWords start
+seek ps = do
+ force <- Annex.getState Annex.force
+ withWords (start force) ps
-start :: [String] -> CommandStart
-start (keyname:file:[]) = do
+start :: Bool -> [String] -> CommandStart
+start force (keyname:file:[]) = do
let key = fromMaybe (error "bad key") $ file2key keyname
- inbackend <- inAnnex key
- unless inbackend $ error $
- "key ("++ keyname ++") is not present in backend"
+ unless force $ do
+ inbackend <- inAnnex key
+ unless inbackend $ error $
+ "key ("++ keyname ++") is not present in backend (use --force to override this sanity check)"
showStart "fromkey" file
next $ perform key file
-start _ = error "specify a key and a dest file"
+start _ _ = error "specify a key and a dest file"
perform :: Key -> FilePath -> CommandPerform
perform key file = do