diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-10 02:27:14 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-10 02:27:14 -0400 |
commit | 058cef945023843219e09d4cec80bb7e137b9876 (patch) | |
tree | f9d340cd3688ab918c5faf853fa0e0f97b5027c3 /GitRepo.hs | |
parent | 852ead470756744cd6663ee2d537f3d281f1e7c8 (diff) |
handle bare repo right for gitattributes
also simplere code!
Diffstat (limited to 'GitRepo.hs')
-rw-r--r-- | GitRepo.hs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/GitRepo.hs b/GitRepo.hs index 21c683bd2..2e2c1d52b 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -32,21 +32,26 @@ gitRelative repo file = drop (length absrepo) absfile {- Sets up the current git repo for git-annex. May be called repeatedly. -} gitPrep :: IO () gitPrep = do - repo <- repoTop - bare <- isBareRepo repo -- configure git to use union merge driver on state files - let attributes = repo ++ "/.gitattributes" let attrLine = stateLoc ++ "/* merge=union" + attributes <- gitAttributes exists <- doesFileExist attributes - if (not bare) - then if (not exists) - then writeFile attributes $ attrLine ++ "\n" - else do - content <- readFile attributes - if (all (/= attrLine) (lines content)) - then appendFile attributes $ attrLine ++ "\n" - else return () - else return () + if (not exists) + then writeFile attributes $ attrLine ++ "\n" + else do + content <- readFile attributes + if (all (/= attrLine) (lines content)) + then appendFile attributes $ attrLine ++ "\n" + else return () + +{- Returns the path to the current repository's gitattributes file. -} +gitAttributes :: IO String +gitAttributes = do + repo <- repoTop + bare <- isBareRepo repo + if (bare) + then return $ repo ++ "/info/.gitattributes" + else return $ repo ++ "/.gitattributes" {- Returns the path to the current repository's .git directory. - (For a bare repository, that is the root of the repository.) @@ -56,7 +61,7 @@ gitDir = do repo <- repoTop bare <- isBareRepo repo if (bare) - then return repo + then return $ repo else return $ repo ++ "/.git" {- Finds the top of the current git repository, which may be in a parent |