summaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-11 00:19:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-11 00:19:38 -0400
commit2bd3eea0318fe52452fa7077fe94ae3f224ae9c5 (patch)
tree8597b882848fba48ac67d1ca84361e0dc5c3b516 /GitRepo.hs
parentc5d7ca0a5a2c6837d394e23d1a18a1005ee6f1b6 (diff)
add git config lookups for annex.name, annex.backends, etc
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index ef76fb976..3a8a8110d 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -5,7 +5,10 @@ module GitRepo where
import Directory
import System.Directory
import System.Path
+import System.Cmd.Utils
+import System.IO
import Data.String.Utils
+import Control.Exception
import Utility
import Types
@@ -14,11 +17,9 @@ gitRepo :: FilePath -> IO GitRepo
gitRepo dir = do
b <- isBareRepo dir
- -- TOOD query repo for configuration settings; other repositories; etc
return GitRepo {
top = dir,
- bare = b,
- remotes = []
+ bare = b
}
{- Path to a repository's gitattributes file. -}
@@ -53,10 +54,19 @@ gitRelative repo file = drop (length absrepo) absfile
Nothing -> error $ file ++ " is not located inside git repository " ++ absrepo
{- Stages a changed file in git's index. -}
+gitAdd :: GitRepo -> FilePath -> IO ()
gitAdd repo file = do
-- TODO
return ()
+{- Queries git-config. -}
+gitConfigGet :: String -> String -> IO String
+gitConfigGet name defaultValue =
+ handle ((\_ -> return defaultValue)::SomeException -> IO String) $
+ pOpen ReadFromPipe "git" ["config", "--get", name] $ \h -> do
+ ret <- hGetLine h
+ return ret
+
{- Finds the current git repository, which may be in a parent directory. -}
currentRepo :: IO GitRepo
currentRepo = do