broke out Git/HashObject.hs
This commit is contained in:
parent
31a0c07ee9
commit
0e45b762a0
2 changed files with 32 additions and 16 deletions
29
Git/HashObject.hs
Normal file
29
Git/HashObject.hs
Normal file
|
@ -0,0 +1,29 @@
|
|||
{- git hash-object interface
|
||||
-
|
||||
- Copyright 2011 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Git.HashObject where
|
||||
|
||||
import Common
|
||||
import Git
|
||||
|
||||
{- Injects a set of files into git, returning the shas of the objects. -}
|
||||
hashFiles :: [FilePath] -> Repo -> IO [Sha]
|
||||
hashFiles paths repo = do
|
||||
(pid, fromh, toh) <- hPipeBoth "git" $ toCommand $ git_hash_object repo
|
||||
_ <- forkProcess (feeder toh)
|
||||
hClose toh
|
||||
shas <- map Git.Ref . lines <$> hGetContents fromh
|
||||
hClose fromh
|
||||
forceSuccess pid
|
||||
return shas
|
||||
where
|
||||
git_hash_object = Git.gitCommandLine
|
||||
[Param "hash-object", Param "-w", Param "--stdin-paths"]
|
||||
feeder toh = do
|
||||
hPutStr toh $ unlines paths
|
||||
hClose toh
|
||||
exitSuccess
|
Loading…
Add table
Add a link
Reference in a new issue