summaryrefslogtreecommitdiff
path: root/Git/LsTree.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Git/LsTree.hs')
-rw-r--r--Git/LsTree.hs19
1 files changed, 12 insertions, 7 deletions
diff --git a/Git/LsTree.hs b/Git/LsTree.hs
index 6e4cd8470..956f9f5b4 100644
--- a/Git/LsTree.hs
+++ b/Git/LsTree.hs
@@ -8,6 +8,7 @@
module Git.LsTree (
TreeItem(..),
lsTree,
+ lsTreeParams,
lsTreeFiles,
parseLsTree
) where
@@ -20,26 +21,30 @@ import Common
import Git
import Git.Command
import Git.Sha
+import Git.FilePath
import qualified Git.Filename
data TreeItem = TreeItem
{ mode :: FileMode
, typeobj :: String
, sha :: String
- , file :: FilePath
+ , file :: TopFilePath
} deriving Show
-{- Lists the complete contents of a tree, with lazy output. -}
+{- Lists the complete contents of a tree, recursing into sub-trees,
+ - with lazy output. -}
lsTree :: Ref -> Repo -> IO [TreeItem]
-lsTree t repo = map parseLsTree <$> pipeNullSplitZombie ps repo
- where
- ps = [Params "ls-tree --full-tree -z -r --", File $ show t]
+lsTree t repo = map parseLsTree
+ <$> pipeNullSplitZombie (lsTreeParams t) repo
+
+lsTreeParams :: Ref -> [CommandParam]
+lsTreeParams t = [ Params "ls-tree --full-tree -z -r --", File $ show t ]
{- Lists specified files in a tree. -}
lsTreeFiles :: Ref -> [FilePath] -> Repo -> IO [TreeItem]
lsTreeFiles t fs repo = map parseLsTree <$> pipeNullSplitStrict ps repo
where
- ps = [Params "ls-tree -z --", File $ show t] ++ map File fs
+ ps = [Params "ls-tree --full-tree -z --", File $ show t] ++ map File fs
{- Parses a line of ls-tree output.
- (The --long format is not currently supported.) -}
@@ -48,7 +53,7 @@ parseLsTree l = TreeItem
{ mode = fst $ Prelude.head $ readOct m
, typeobj = t
, sha = s
- , file = Git.Filename.decode f
+ , file = asTopFilePath $ Git.Filename.decode f
}
where
-- l = <mode> SP <type> SP <sha> TAB <file>