diff options
author | Joey Hess <joey@kitenet.net> | 2011-03-03 16:22:53 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-03-03 16:22:53 -0400 |
commit | b88637fff10d4d845404882e4ec95cfc071dcac0 (patch) | |
tree | c4e2067d6bbe2a8de44c2bc25212473409bb4802 /Command.hs | |
parent | a9d0538da559c29509c50b664e31ea3b23b7bc14 (diff) |
prevent trust commands from trying to do things in a bare repo
Since they need to stage changes, they would actually, if allowed to run,
succeed, but wipe out existing trust.log content.
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Command.hs b/Command.hs index 86da45419..d54a7052e 100644 --- a/Command.hs +++ b/Command.hs @@ -10,7 +10,7 @@ module Command where import Control.Monad.State (liftIO) import System.Directory import System.Posix.Files -import Control.Monad (filterM, liftM) +import Control.Monad (filterM, liftM, when) import System.Path.WildMatch import Text.Regex.PCRE.Light.Char8 import Data.List @@ -104,6 +104,13 @@ isAnnexed file a = do Just v -> a v Nothing -> return Nothing +notBareRepo :: Annex a -> Annex a +notBareRepo a = do + g <- Annex.gitRepo + when (Git.repoIsLocalBare g) $ do + error "You cannot run this subcommand in a bare repository." + a + {- These functions find appropriate files or other things based on a user's parameters, and run a specified action on them. -} withFilesInGit :: CommandSeekStrings |