From f7dc20595ed9a6d3cf61b4ab78ecf57ef62d761f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 6 Jul 2015 14:21:43 -0400 Subject: [PATCH] refactor ls-tree params All in one place to avoid bugs like 174da80ddcd220815a1e9b6c24df955734b41cd1 --- Annex/Branch.hs | 11 +++-------- Git/LsTree.hs | 11 ++++++----- Git/Repair.hs | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Annex/Branch.hs b/Annex/Branch.hs index 286eb05585..c6c9b99497 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -43,6 +43,7 @@ import qualified Git.Sha import qualified Git.Branch import qualified Git.UnionMerge import qualified Git.UpdateIndex +import Git.LsTree (lsTreeParams) import Git.HashObject import Git.Types import Git.FilePath @@ -314,14 +315,8 @@ files = do {- Files in the branch, not including any from journalled changes, - and without updating the branch. -} branchFiles :: Annex [FilePath] -branchFiles = withIndex $ inRepo $ Git.Command.pipeNullSplitZombie - [ Param "ls-tree" - , Param "--full-tree" - , Param "--name-only" - , Param "-r" - , Param "-z" - , Param $ fromRef fullname - ] +branchFiles = withIndex $ inRepo $ Git.Command.pipeNullSplitZombie $ + lsTreeParams fullname [Param "--name-only"] {- Populates the branch's index file with the current branch contents. - diff --git a/Git/LsTree.hs b/Git/LsTree.hs index bce6350962..1ed62477e4 100644 --- a/Git/LsTree.hs +++ b/Git/LsTree.hs @@ -34,16 +34,17 @@ data TreeItem = TreeItem - with lazy output. -} lsTree :: Ref -> Repo -> IO [TreeItem] lsTree t repo = map parseLsTree - <$> pipeNullSplitZombie (lsTreeParams t) repo + <$> pipeNullSplitZombie (lsTreeParams t []) repo -lsTreeParams :: Ref -> [CommandParam] -lsTreeParams t = +lsTreeParams :: Ref -> [CommandParam] -> [CommandParam] +lsTreeParams r ps = [ Param "ls-tree" , Param "--full-tree" , Param "-z" , Param "-r" - , Param "--" - , File $ fromRef t + ] ++ ps ++ + [ Param "--" + , File $ fromRef r ] {- Lists specified files in a tree. -} diff --git a/Git/Repair.hs b/Git/Repair.hs index 46cf221230..b441f13379 100644 --- a/Git/Repair.hs +++ b/Git/Repair.hs @@ -341,7 +341,7 @@ verifyTree :: MissingObjects -> Sha -> Repo -> IO Bool verifyTree missing treesha r | S.member treesha missing = return False | 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 if any isNothing objshas || any (`S.member` missing) (catMaybes objshas) then do