Note that on Windows a remote with a path like /home/foo/bar is interpreted by git as being some screwy relative path (relative to what exactly seems ill-defined -- it seemed relative to C:\Program Files\Git\ in my tests!) So no attempt has been made to handle such a path sanely, just not to crash when encountering it. Note that "C:\\foo" </> "/home/foo/bar" yields /home/foo/bar even though that is not absolute! I don't know what to make of all this, except that I will be very happy when this crock of **** vanishes from the face of the earth.
		
			
				
	
	
		
			36 lines
		
	
	
	
		
			836 B
			
		
	
	
	
		
			Haskell
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
	
		
			836 B
			
		
	
	
	
		
			Haskell
		
	
	
	
	
	
{- 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 Git.FilePath
 | 
						|
 | 
						|
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 (absoluteGitPath f) && not ("../" `isPrefixOf` f)
 | 
						|
 | 
						|
direct :: Field
 | 
						|
direct = Field "direct" $ \f -> f == "1"
 |