summaryrefslogtreecommitdiff
path: root/Git/UpdateIndex.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Git/UpdateIndex.hs')
-rw-r--r--Git/UpdateIndex.hs15
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