add debugging
This commit is contained in:
parent
1d5582091e
commit
182526ff68
8 changed files with 25 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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. -}
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue