refactor ls-tree params

All in one place to avoid bugs like 174da80ddc
This commit is contained in:
Joey Hess 2015-07-06 14:21:43 -04:00
parent 174da80ddc
commit f7dc20595e
3 changed files with 10 additions and 14 deletions

View file

@ -43,6 +43,7 @@ import qualified Git.Sha
import qualified Git.Branch import qualified Git.Branch
import qualified Git.UnionMerge import qualified Git.UnionMerge
import qualified Git.UpdateIndex import qualified Git.UpdateIndex
import Git.LsTree (lsTreeParams)
import Git.HashObject import Git.HashObject
import Git.Types import Git.Types
import Git.FilePath import Git.FilePath
@ -314,14 +315,8 @@ files = do
{- Files in the branch, not including any from journalled changes, {- Files in the branch, not including any from journalled changes,
- and without updating the branch. -} - and without updating the branch. -}
branchFiles :: Annex [FilePath] branchFiles :: Annex [FilePath]
branchFiles = withIndex $ inRepo $ Git.Command.pipeNullSplitZombie branchFiles = withIndex $ inRepo $ Git.Command.pipeNullSplitZombie $
[ Param "ls-tree" lsTreeParams fullname [Param "--name-only"]
, Param "--full-tree"
, Param "--name-only"
, Param "-r"
, Param "-z"
, Param $ fromRef fullname
]
{- Populates the branch's index file with the current branch contents. {- Populates the branch's index file with the current branch contents.
- -

View file

@ -34,16 +34,17 @@ data TreeItem = TreeItem
- with lazy output. -} - with lazy output. -}
lsTree :: Ref -> Repo -> IO [TreeItem] lsTree :: Ref -> Repo -> IO [TreeItem]
lsTree t repo = map parseLsTree lsTree t repo = map parseLsTree
<$> pipeNullSplitZombie (lsTreeParams t) repo <$> pipeNullSplitZombie (lsTreeParams t []) repo
lsTreeParams :: Ref -> [CommandParam] lsTreeParams :: Ref -> [CommandParam] -> [CommandParam]
lsTreeParams t = lsTreeParams r ps =
[ Param "ls-tree" [ Param "ls-tree"
, Param "--full-tree" , Param "--full-tree"
, Param "-z" , Param "-z"
, Param "-r" , Param "-r"
, Param "--" ] ++ ps ++
, File $ fromRef t [ Param "--"
, File $ fromRef r
] ]
{- Lists specified files in a tree. -} {- Lists specified files in a tree. -}

View file

@ -341,7 +341,7 @@ verifyTree :: MissingObjects -> Sha -> Repo -> IO Bool
verifyTree missing treesha r verifyTree missing treesha r
| S.member treesha missing = return False | S.member treesha missing = return False
| otherwise = do | otherwise = do
(ls, cleanup) <- pipeNullSplit (LsTree.lsTreeParams treesha) r (ls, cleanup) <- pipeNullSplit (LsTree.lsTreeParams treesha []) r
let objshas = map (extractSha . LsTree.sha . LsTree.parseLsTree) ls let objshas = map (extractSha . LsTree.sha . LsTree.parseLsTree) ls
if any isNothing objshas || any (`S.member` missing) (catMaybes objshas) if any isNothing objshas || any (`S.member` missing) (catMaybes objshas)
then do then do