diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-02-23 17:21:42 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-02-23 17:21:42 -0400 |
commit | b2f63a097331b8e3b5a1fe177686da1dc412b723 (patch) | |
tree | 5238391a9ae5af456e65886d985fabd5cea1f1ec | |
parent | 7bd41a5ebf4e181199cb0819c52acb362ca9d552 (diff) |
minor improvements
-rw-r--r-- | Git/Tree.hs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Git/Tree.hs b/Git/Tree.hs index 75e3f3c7a..290c88249 100644 --- a/Git/Tree.hs +++ b/Git/Tree.hs @@ -42,6 +42,8 @@ getTree r repo = do let t = either (\e -> error ("ls-tree parse error:" ++ e)) id (extractTree l) return (t, cleanup) +{- Assumes the list is ordered, with tree objects coming right before their + - contents. -} extractTree :: [LsTree.TreeItem] -> Either String Tree extractTree l = case go [] "" l of Right (t, []) -> Right (Tree t) @@ -72,7 +74,7 @@ extractTree l = case go [] "" l of - interface. -} recordTree :: Repo -> Tree -> IO Sha -recordTree repo (Tree t) = do +recordTree repo t = do h <- CoProcess.rawMode =<< gitCoProcessStart False ps repo sha <- recordTree' h t CoProcess.stop h @@ -80,8 +82,8 @@ recordTree repo (Tree t) = do where ps = [Param "mktree", Param "--batch", Param "-z"] -recordTree' :: CoProcess.CoProcessHandle -> [TreeContent] -> IO Sha -recordTree' h l = mkTree h =<< mapM (recordSubTree h) l +recordTree' :: CoProcess.CoProcessHandle -> Tree -> IO Sha +recordTree' h (Tree l) = mkTree h =<< mapM (recordSubTree h) l recordSubTree :: CoProcess.CoProcessHandle -> TreeContent -> IO TreeContent recordSubTree h (NewSubTree d l) = do @@ -102,4 +104,13 @@ mkTree cp l = CoProcess.query cp send receive receive h = Ref <$> hGetLine h mkTreeOutput :: FileMode -> ObjectType -> Sha -> TopFilePath -> String -mkTreeOutput fm ot s f = showOct fm "" ++ " " ++ show ot ++ " " ++ fromRef s ++ "\t" ++ takeFileName (getTopFilePath f) ++ "\NUL" +mkTreeOutput fm ot s f = concat + [ showOct fm "" + , " " + , show ot + , " " + , fromRef s + , "\t" + , takeFileName (getTopFilePath f) + , "\NUL" + ] |