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:
Joey Hess 2012-12-29 14:45:19 -04:00
parent e2788a5d15
commit e872c3f648
10 changed files with 26 additions and 28 deletions

View file

@ -24,7 +24,7 @@ import Types.KeySource
import Config
def :: [Command]
def = [notDirect $ withOptions [fileOption, pathdepthOption] $
def = [notDirect $ notBareRepo $ withOptions [fileOption, pathdepthOption] $
command "addurl" (paramRepeating paramUrl) seek "add urls to annex"]
fileOption :: Option
@ -39,7 +39,7 @@ seek = [withField fileOption return $ \f ->
withStrings $ start f d]
start :: Maybe FilePath -> Maybe Int -> String -> CommandStart
start optfile pathdepth s = notBareRepo $ go $ fromMaybe bad $ parseURI s
start optfile pathdepth s = go $ fromMaybe bad $ parseURI s
where
bad = fromMaybe (error $ "bad url " ++ s) $
parseURI $ escapeURIString isUnescapedInURI s