From df48567279fa504ca31d9f4f25b06066f08d1128 Mon Sep 17 00:00:00 2001 From: guilhem Date: Mon, 26 Aug 2013 02:47:49 +0200 Subject: Speed up the 'unused' command. Instead of populating the second-level Bloom filter with every key referenced in every Git reference, consider only those which differ from what's referenced in the index. Incidentaly, unlike with its old behavior, staged modifications/deletion/... will now be detected by 'unused'. Credits to joeyh for the algorithm. :-) --- Git/DiffTree.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Git/DiffTree.hs') diff --git a/Git/DiffTree.hs b/Git/DiffTree.hs index cf8a37600..8f85fcc34 100644 --- a/Git/DiffTree.hs +++ b/Git/DiffTree.hs @@ -41,14 +41,14 @@ diffTreeRecursive :: Ref -> Ref -> Repo -> IO ([DiffTreeItem], IO Bool) diffTreeRecursive src dst = getdiff (Param "diff-tree") [Param "-r", Param (show src), Param (show dst)] -{- Diffs between the repository and index. Does nothing if there is not - - yet a commit in the repository. -} -diffIndex :: Repo -> IO ([DiffTreeItem], IO Bool) -diffIndex repo = do +{- Diffs between a tree and the index. Does nothing if there is not yet a + - commit in the repository. -} +diffIndex :: Ref -> Repo -> IO ([DiffTreeItem], IO Bool) +diffIndex ref repo = do ifM (Git.Ref.headExists repo) ( getdiff (Param "diff-index") [ Param "--cached" - , Param $ show Git.Ref.headRef + , Param $ show ref ] repo , return ([], return True) ) -- cgit v1.2.3