summaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-26 16:37:27 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-26 16:37:27 -0400
commitf4a0908ce1fa79247d5cd8362f942dbbc6f22a85 (patch)
tree72964730caa44e8c0ab97f4ccdd7538c67254d0e /CmdLine
parentda0b9c92faa431199589d2d9ea98ea60af6a333f (diff)
re-add
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/GitAnnexShell/Fields.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/CmdLine/GitAnnexShell/Fields.hs b/CmdLine/GitAnnexShell/Fields.hs
new file mode 100644
index 000000000..e71f2c2a0
--- /dev/null
+++ b/CmdLine/GitAnnexShell/Fields.hs
@@ -0,0 +1,35 @@
+{- git-annex-shell fields
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module CmdLine.GitAnnexShell.Fields where
+
+import Common.Annex
+import qualified Annex
+
+import Data.Char
+
+{- A field, stored in Annex state, with a value sanity checker. -}
+data Field = Field
+ { fieldName :: String
+ , fieldCheck :: String -> Bool
+ }
+
+getField :: Field -> Annex (Maybe String)
+getField = Annex.getField . fieldName
+
+remoteUUID :: Field
+remoteUUID = Field "remoteuuid" $
+ -- does it look like a UUID?
+ all (\c -> isAlphaNum c || c == '-')
+
+associatedFile :: Field
+associatedFile = Field "associatedfile" $ \f ->
+ -- is the file a safe relative filename?
+ not (isAbsolute f) && not ("../" `isPrefixOf` f)
+
+direct :: Field
+direct = Field "direct" $ \f -> f == "1"