Now "git annex init" only has to be run once
when a git repository is first being created. Clones will automatically notice that git-annex is in use and automatically perform a basic initalization. It's still recommended to run "git annex init" in any clones, to describe them.
This commit is contained in:
parent
3b5f722130
commit
56f6923ccb
7 changed files with 127 additions and 66 deletions
22
CmdLine.hs
22
CmdLine.hs
|
@ -19,13 +19,14 @@ import Control.Monad (when)
|
|||
import qualified Annex
|
||||
import qualified AnnexQueue
|
||||
import qualified Git
|
||||
import qualified Branch
|
||||
import Content
|
||||
import Types
|
||||
import Command
|
||||
import Version
|
||||
import Options
|
||||
import Messages
|
||||
import UUID
|
||||
import Init
|
||||
|
||||
{- Runs the passed command line. -}
|
||||
dispatch :: [String] -> [Command] -> [Option] -> String -> Git.Repo -> IO ()
|
||||
|
@ -45,7 +46,7 @@ parseCmd argv header cmds options = do
|
|||
[] -> error $ "unknown command" ++ usagemsg
|
||||
[command] -> do
|
||||
_ <- sequence flags
|
||||
when (cmdusesrepo command) checkVersion
|
||||
checkCmdEnviron command
|
||||
prepCommand command (drop 1 params)
|
||||
_ -> error "internal error: multiple matching commands"
|
||||
where
|
||||
|
@ -57,6 +58,19 @@ parseCmd argv header cmds options = do
|
|||
lookupCmd cmd = filter (\c -> cmd == cmdname c) cmds
|
||||
usagemsg = "\n\n" ++ usage header cmds options
|
||||
|
||||
{- Checks that the command can be run in the current environment. -}
|
||||
checkCmdEnviron :: Command -> Annex ()
|
||||
checkCmdEnviron command = do
|
||||
when (cmdusesrepo command) $ checkVersion $ do
|
||||
{- Automatically initialize if there is already a git-annex
|
||||
branch from somewhere. Otherwise, require a manual init
|
||||
to avoid git-annex accidentially being run in git
|
||||
repos that did not intend to use it. -}
|
||||
annexed <- Branch.hasSomeBranch
|
||||
if annexed
|
||||
then initialize
|
||||
else error "First run: git-annex init"
|
||||
|
||||
{- Usage message with lists of commands and options. -}
|
||||
usage :: String -> [Command] -> [Option] -> String
|
||||
usage header cmds options =
|
||||
|
@ -95,9 +109,7 @@ tryRun' errnum _ [] = when (errnum > 0) $ error $ show errnum ++ " failed"
|
|||
|
||||
{- Actions to perform each time ran. -}
|
||||
startup :: Annex Bool
|
||||
startup = do
|
||||
prepUUID
|
||||
return True
|
||||
startup = return True
|
||||
|
||||
{- Cleanup actions. -}
|
||||
shutdown :: Annex Bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue