diff options
author | 2012-12-29 14:45:19 -0400 | |
---|---|---|
committer | 2012-12-29 14:45:19 -0400 | |
commit | 992eb6d6931cfc2ca8da0fe2d25e58742ce8cd77 (patch) | |
tree | cb1b35a324ee240fc2291b847e96e46944e5fbfc /Command | |
parent | a2acf0ed7f27bf4ce37be39d1c5f47c414183ead (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 'Command')
-rw-r--r-- | Command/Add.hs | 5 | ||||
-rw-r--r-- | Command/AddUrl.hs | 4 | ||||
-rw-r--r-- | Command/Direct.hs | 7 | ||||
-rw-r--r-- | Command/FromKey.hs | 7 | ||||
-rw-r--r-- | Command/Import.hs | 4 | ||||
-rw-r--r-- | Command/Indirect.hs | 7 | ||||
-rw-r--r-- | Command/Watch.hs | 4 | ||||
-rw-r--r-- | Command/WebApp.hs | 4 |
8 files changed, 21 insertions, 21 deletions
diff --git a/Command/Add.hs b/Command/Add.hs index 9f203346f..b3181cfd7 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -23,7 +23,8 @@ import Utility.FileMode import Config def :: [Command] -def = [notDirect $ command "add" paramPaths seek "add files to annex"] +def = [notDirect $ notBareRepo $ + command "add" paramPaths seek "add files to annex"] {- Add acts on both files not checked into git yet, and unlocked files. -} seek :: [CommandSeek] @@ -33,7 +34,7 @@ seek = [withFilesNotInGit start, withFilesUnlocked start] - backend, and then moving it into the annex directory and setting up - the symlink pointing to its content. -} start :: FilePath -> CommandStart -start file = notBareRepo $ ifAnnexed file fixup add +start file = ifAnnexed file fixup add where add = do s <- liftIO $ getSymbolicLinkStatus file diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index dca515b70..9c6e8aa86 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -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 diff --git a/Command/Direct.hs b/Command/Direct.hs index 8e7f40145..0c007bb10 100644 --- a/Command/Direct.hs +++ b/Command/Direct.hs @@ -16,15 +16,14 @@ import Config import Annex.Direct def :: [Command] -def = [command "direct" paramNothing seek "switch repository to direct mode"] +def = [notBareRepo $ + command "direct" paramNothing seek "switch repository to direct mode"] seek :: [CommandSeek] seek = [withNothing start] start :: CommandStart -start = notBareRepo $ - ifM isDirect - ( stop , next perform ) +start = ifM isDirect ( stop , next perform ) perform :: CommandPerform perform = do diff --git a/Command/FromKey.hs b/Command/FromKey.hs index a2ab55c9c..d023be686 100644 --- a/Command/FromKey.hs +++ b/Command/FromKey.hs @@ -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 $ diff --git a/Command/Import.hs b/Command/Import.hs index fc1bf5b4b..e8e839e4f 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -13,14 +13,14 @@ import qualified Annex import qualified Command.Add def :: [Command] -def = [notDirect $ command "import" paramPaths seek +def = [notDirect $ notBareRepo $ command "import" paramPaths seek "move and add files from outside git working copy"] seek :: [CommandSeek] seek = [withPathContents start] start :: (FilePath, FilePath) -> CommandStart -start (srcfile, destfile) = notBareRepo $ +start (srcfile, destfile) = ifM (liftIO $ isRegularFile <$> getSymbolicLinkStatus srcfile) ( do showStart "import" destfile diff --git a/Command/Indirect.hs b/Command/Indirect.hs index 058a7b750..168d837ff 100644 --- a/Command/Indirect.hs +++ b/Command/Indirect.hs @@ -18,15 +18,14 @@ import Annex.Content import Annex.CatFile def :: [Command] -def = [command "indirect" paramNothing seek "switch repository to indirect mode"] +def = [notBareRepo $ command "indirect" paramNothing seek + "switch repository to indirect mode"] seek :: [CommandSeek] seek = [withNothing start] start :: CommandStart -start = notBareRepo $ - ifM isDirect - ( next perform, stop ) +start = ifM isDirect ( next perform, stop ) perform :: CommandPerform perform = do diff --git a/Command/Watch.hs b/Command/Watch.hs index eb70ef6b1..25b5c6bba 100644 --- a/Command/Watch.hs +++ b/Command/Watch.hs @@ -13,7 +13,7 @@ import Command import Option def :: [Command] -def = [withOptions [foregroundOption, stopOption] $ +def = [notBareRepo $ withOptions [foregroundOption, stopOption] $ command "watch" paramNothing seek "watch for changes"] seek :: [CommandSeek] @@ -28,7 +28,7 @@ stopOption :: Option stopOption = Option.flag [] "stop" "stop daemon" start :: Bool -> Bool -> Bool -> CommandStart -start assistant foreground stopdaemon = notBareRepo $ do +start assistant foreground stopdaemon = do if stopdaemon then stopDaemon else startDaemon assistant foreground Nothing -- does not return diff --git a/Command/WebApp.hs b/Command/WebApp.hs index 11ba23d83..581d6d4dd 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -29,7 +29,7 @@ import Control.Concurrent import Control.Concurrent.STM def :: [Command] -def = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $ +def = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $ notBareRepo $ command "webapp" paramNothing seek "launch webapp"] seek :: [CommandSeek] @@ -39,7 +39,7 @@ start :: CommandStart start = start' True start' :: Bool -> CommandStart -start' allowauto = notBareRepo $ do +start' allowauto = do liftIO $ ensureInstalled ifM isInitialized ( go , auto ) stop |