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. :-)
This commit is contained in:
guilhem 2013-08-26 02:47:49 +02:00 committed by Joey Hess
parent 2794f4fb48
commit f15fda60ed
4 changed files with 32 additions and 26 deletions

View file

@ -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)
)