summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar guilhem <guilhem@fripost.org>2013-08-26 02:47:49 +0200
committerGravatar Joey Hess <joey@kitenet.net>2013-08-25 21:02:13 -0400
commitdf48567279fa504ca31d9f4f25b06066f08d1128 (patch)
tree8b40f2d55abe2e74f870696db131536c43794116 /Git
parentb20ea840b89f7b1584b3cadcc195508ff824ad54 (diff)
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. :-)
Diffstat (limited to 'Git')
-rw-r--r--Git/DiffTree.hs10
1 files changed, 5 insertions, 5 deletions
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)
)