summaryrefslogtreecommitdiff
path: root/git-annex-shell.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-06 19:11:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-06 19:24:11 -0400
commit5414bbce58041aa92f2a50a8e721507879000f77 (patch)
tree7e9bb34e6be4a52d266da351c747a6dd71c33d06 /git-annex-shell.hs
parentf011033869bbeeb7941c1c6e16a2a138b11c92e4 (diff)
git-annex-shell uuid verification
* git-annex now asks git-annex-shell to verify that it's operating in the expected repository. * Note that this git-annex will not interoperate with remotes using older versions of git-annex-shell. The reason for this check is to avoid git-annex getting confused about what remote repository actually contains a value. It's a prerequisite for supporting git insteadOf aliases.
Diffstat (limited to 'git-annex-shell.hs')
-rw-r--r--git-annex-shell.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/git-annex-shell.hs b/git-annex-shell.hs
index 2e0d30979..79b5da69a 100644
--- a/git-annex-shell.hs
+++ b/git-annex-shell.hs
@@ -6,12 +6,14 @@
-}
import System.Environment
+import System.Console.GetOpt
import Common.Annex
import qualified Git
import CmdLine
import Command
import Options
+import UUID
import qualified Command.ConfigList
import qualified Command.InAnnex
@@ -30,6 +32,16 @@ cmds = map adddirparam $ concat
where
adddirparam c = c { cmdparams = "DIRECTORY " ++ cmdparams c }
+options :: [OptDescr (Annex ())]
+options = uuid : commonOptions
+ where
+ uuid = Option [] ["uuid"] (ReqArg check paramUUID) "repository uuid"
+ check expected = do
+ u <- getUUID =<< gitRepo
+ when (u /= expected) $ error $
+ "expected repository UUID " ++ expected
+ ++ " but found UUID " ++ u
+
header :: String
header = "Usage: git-annex-shell [-c] command [parameters ...] [option ..]"
@@ -57,7 +69,7 @@ builtins = map cmdname cmds
builtin :: String -> String -> [String] -> IO ()
builtin cmd dir params =
Git.repoAbsPath dir >>= Git.repoFromAbsPath >>=
- dispatch (cmd : filterparams params) cmds commonOptions header
+ dispatch (cmd : filterparams params) cmds options header
external :: [String] -> IO ()
external params =
@@ -72,4 +84,4 @@ filterparams ("--":_) = []
filterparams (a:as) = a:filterparams as
failure :: IO ()
-failure = error $ "bad parameters\n\n" ++ usage header cmds commonOptions
+failure = error $ "bad parameters\n\n" ++ usage header cmds options