diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-06 14:26:15 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-06 14:26:15 -0400 |
commit | 91db54076964979b6c50bd7efd0b895c4d416978 (patch) | |
tree | 7ba67f302dac7ef03b2cef906ab08bb88c0f8967 /Git/UpdateIndex.hs | |
parent | 993e6459a38817a9062aafae7552a668c2db7a31 (diff) |
add support for staging other types of blobs, like symlinks, into the index
Also added a utility TopFilePath type, which could stand to be used more
widely.
Diffstat (limited to 'Git/UpdateIndex.hs')
-rw-r--r-- | Git/UpdateIndex.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Git/UpdateIndex.hs b/Git/UpdateIndex.hs index 04bc4da5b..8c003dd13 100644 --- a/Git/UpdateIndex.hs +++ b/Git/UpdateIndex.hs @@ -8,15 +8,17 @@ module Git.UpdateIndex ( Streamer, stream_update_index, + ls_tree, update_index_line, - ls_tree ) where import System.Cmd.Utils import Common import Git +import Git.Types import Git.Command +import Git.FilePath {- Streamers are passed a callback and should feed it lines in the form - read by update-index, and generated by ls-tree. -} @@ -37,13 +39,14 @@ stream_update_index repo as = do hPutStr h s hPutStr h "\0" -{- Generates a line suitable to be fed into update-index, to add - - a given file with a given sha. -} -update_index_line :: Sha -> FilePath -> String -update_index_line sha file = "100644 blob " ++ show sha ++ "\t" ++ file - {- Gets the current tree for a ref. -} ls_tree :: Ref -> Repo -> Streamer ls_tree (Ref x) repo streamer = mapM_ streamer =<< pipeNullSplit params repo where params = map Param ["ls-tree", "-z", "-r", "--full-tree", x] + +{- Generates a line suitable to be fed into update-index, to add + - a given file with a given sha. -} +update_index_line :: Sha -> BlobType -> TopFilePath -> String +update_index_line sha filetype file = + show filetype ++ " blob " ++ show sha ++ "\t" ++ getTopFilePath file |