summaryrefslogtreecommitdiff
path: root/Checks.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-29 14:45:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-29 14:45:19 -0400
commit992eb6d6931cfc2ca8da0fe2d25e58742ce8cd77 (patch)
treecb1b35a324ee240fc2291b847e96e46944e5fbfc /Checks.hs
parenta2acf0ed7f27bf4ce37be39d1c5f47c414183ead (diff)
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.
Diffstat (limited to 'Checks.hs')
-rw-r--r--Checks.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/Checks.hs b/Checks.hs
index 3757abb27..92e9f7e38 100644
--- a/Checks.hs
+++ b/Checks.hs
@@ -14,6 +14,7 @@ import Common.Annex
import Types.Command
import Init
import Config
+import qualified Git
commonChecks :: [CommandCheck]
commonChecks = [repoExists]
@@ -25,6 +26,10 @@ notDirect :: Command -> Command
notDirect = addCheck $ whenM isDirect $
error "You cannot run this subcommand in a direct mode repository."
+notBareRepo :: Command -> Command
+notBareRepo = addCheck $ whenM (fromRepo Git.repoIsLocalBare) $
+ error "You cannot run this subcommand in a bare repository."
+
dontCheck :: CommandCheck -> Command -> Command
dontCheck check cmd = mutateCheck cmd $ \c -> filter (/= check) c