summaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-10 13:47:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-10 13:47:04 -0400
commit80ce5f90db1de10a5fa42583efcb7390cf185662 (patch)
tree7c94bbb23f893b1275aa756afd20ca6c5c8337c3 /GitRepo.hs
parenta55f49efb6c05c5ddb031f077690e90ed7358642 (diff)
update
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index 140fb628a..8974d9db6 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -8,14 +8,16 @@ import System.Path
import Data.String.Utils
import Utility
+type GitRepo = FilePath
+
{- Long-term state is stored in files inside the .git-annex directory
- in the git repository. -}
stateLoc = ".git-annex"
-gitStateDir :: String -> String
+gitStateDir :: GitRepo -> FilePath
gitStateDir repo = repo ++ "/" ++ stateLoc ++ "/"
{- Path to a repository's gitattributes file. -}
-gitAttributes :: FilePath -> IO String
+gitAttributes :: GitRepo -> IO String
gitAttributes repo = do
bare <- isBareRepo repo
if (bare)
@@ -25,7 +27,7 @@ gitAttributes repo = do
{- Path to a repository's .git directory.
- (For a bare repository, that is the root of the repository.)
- TODO: support GIT_DIR -}
-gitDir :: FilePath -> IO String
+gitDir :: GitRepo -> IO String
gitDir repo = do
bare <- isBareRepo repo
if (bare)
@@ -35,7 +37,7 @@ gitDir repo = do
{- Given a relative or absolute filename, calculates the name to use
- relative to a git repository directory (which must be absolute).
- This is the same form displayed and used by git. -}
-gitRelative :: FilePath -> String -> String
+gitRelative :: GitRepo -> String -> String
gitRelative repo file = drop (length absrepo) absfile
where
-- normalize both repo and file, so that repo
@@ -48,7 +50,7 @@ gitRelative repo file = drop (length absrepo) absfile
Nothing -> error $ file ++ " is not located inside git repository " ++ absrepo
{- Sets up a git repo for git-annex. May be called repeatedly. -}
-gitPrep :: FilePath -> IO ()
+gitPrep :: GitRepo -> IO ()
gitPrep repo = do
-- configure git to use union merge driver on state files
let attrLine = stateLoc ++ "/* merge=union"
@@ -66,7 +68,7 @@ gitPrep repo = do
{- Finds the top of the current git repository, which may be in a parent
- directory. -}
-repoTop :: IO String
+repoTop :: IO GitRepo
repoTop = do
cwd <- getCurrentDirectory
top <- seekUp cwd isRepoTop