convert notBareRepo to a CommandCheck
This avoids some small overhead by only running the check once per command; it also ensures that, even if the command doesn't find anything to run on, it still fails to run when in a bare repo.
This commit is contained in:
parent
e2788a5d15
commit
e872c3f648
10 changed files with 26 additions and 28 deletions
|
@ -14,14 +14,15 @@ import Annex.Content
|
|||
import Types.Key
|
||||
|
||||
def :: [Command]
|
||||
def = [notDirect $ command "fromkey" (paramPair paramKey paramPath) seek
|
||||
"adds a file using a specific key"]
|
||||
def = [notDirect $ notBareRepo $
|
||||
command "fromkey" (paramPair paramKey paramPath) seek
|
||||
"adds a file using a specific key"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withWords start]
|
||||
|
||||
start :: [String] -> CommandStart
|
||||
start (keyname:file:[]) = notBareRepo $ do
|
||||
start (keyname:file:[]) = do
|
||||
let key = fromMaybe (error "bad key") $ file2key keyname
|
||||
inbackend <- inAnnex key
|
||||
unless inbackend $ error $
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue