summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-17 14:40:05 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-17 14:40:05 -0400
commit182526ff68b1ca68952b4dbd32121e46d4a80e85 (patch)
treeecd7097dca179776a5a92e0da11e7bebe01c6d37 /Git
parent1d5582091e9df550a8b42d0a69bada1d15a1825e (diff)
add debugging
Diffstat (limited to 'Git')
-rw-r--r--Git/Branch.hs10
-rw-r--r--Git/Command.hs12
-rw-r--r--Git/HashObject.hs8
-rw-r--r--Git/Ref.hs5
4 files changed, 19 insertions, 16 deletions
diff --git a/Git/Branch.hs b/Git/Branch.hs
index 6edc1c306..6f3d25186 100644
--- a/Git/Branch.hs
+++ b/Git/Branch.hs
@@ -73,12 +73,12 @@ commit :: String -> Branch -> [Ref] -> Repo -> IO Sha
commit message branch parentrefs repo = do
tree <- getSha "write-tree" $
pipeRead [Param "write-tree"] repo
- sha <- getSha "commit-tree" $
- ignorehandle $ pipeWriteRead
- (map Param $ ["commit-tree", show tree] ++ ps)
- message repo
+ sha <- getSha "commit-tree" $ pipeWriteRead
+ (map Param $ ["commit-tree", show tree] ++ ps)
+ message repo
+ print ("got", sha)
run "update-ref" [Param $ show branch, Param $ show sha] repo
+ print ("update-ref done", sha)
return sha
where
- ignorehandle a = snd <$> a
ps = concatMap (\r -> ["-p", show r]) parentrefs
diff --git a/Git/Command.hs b/Git/Command.hs
index 35f0838ba..9a09300e2 100644
--- a/Git/Command.hs
+++ b/Git/Command.hs
@@ -57,16 +57,18 @@ pipeWrite params s repo = assertLocal repo $ do
hClose h
return p
-{- Runs a git subcommand, feeding it input, and returning its output.
- - You should call either getProcessStatus or forceSuccess on the PipeHandle. -}
-pipeWriteRead :: [CommandParam] -> String -> Repo -> IO (PipeHandle, String)
+{- Runs a git subcommand, feeding it input, and returning its output,
+ - which is expected to be fairly small, since it's all read into memory
+ - strictly. -}
+pipeWriteRead :: [CommandParam] -> String -> Repo -> IO String
pipeWriteRead params s repo = assertLocal repo $ do
(p, from, to) <- hPipeBoth "git" (toCommand $ gitCommandLine params repo)
fileEncoding to
fileEncoding from
_ <- forkIO $ finally (hPutStr to s) (hClose to)
- c <- hGetContents from
- return (p, c)
+ c <- hGetContentsStrict from
+ forceSuccess p
+ return c
{- Reads null terminated output of a git command (as enabled by the -z
- parameter), and splits it. -}
diff --git a/Git/HashObject.hs b/Git/HashObject.hs
index 9f37de5ba..c90c9ec3d 100644
--- a/Git/HashObject.hs
+++ b/Git/HashObject.hs
@@ -38,11 +38,9 @@ hashFile h file = CoProcess.query h send receive
{- Injects some content into git, returning its Sha. -}
hashObject :: ObjectType -> String -> Repo -> IO Sha
hashObject objtype content repo = getSha subcmd $ do
- (h, s) <- pipeWriteRead (map Param params) content repo
- length s `seq` do
- forceSuccess h
- reap -- XXX unsure why this is needed
- return s
+ s <- pipeWriteRead (map Param params) content repo
+ reap -- XXX unsure why this is needed, of if it is anymore
+ return s
where
subcmd = "hash-object"
params = [subcmd, "-t", show objtype, "-w", "--stdin"]
diff --git a/Git/Ref.hs b/Git/Ref.hs
index ee2f02187..3052d0a6e 100644
--- a/Git/Ref.hs
+++ b/Git/Ref.hs
@@ -40,7 +40,10 @@ exists ref = runBool "show-ref"
{- Get the sha of a fully qualified git ref, if it exists. -}
sha :: Branch -> Repo -> IO (Maybe Sha)
-sha branch repo = process <$> showref repo
+sha branch repo = do
+ r <- process <$> showref repo
+ print r
+ return r
where
showref = pipeRead [Param "show-ref",
Param "--hash", -- get the hash