summaryrefslogtreecommitdiff
path: root/Command/Unused.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-16 02:23:34 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-16 02:41:46 -0400
commit9290095fc21953cd1fe0a71f7c8a454934194e3b (patch)
treec4ac1373ca1961e5f76ba80b840491b7077c5ab9 /Command/Unused.hs
parent272a67921cdc6d8d40641a9cb71b744ef1f76128 (diff)
improve type signatures with a Ref newtype
In git, a Ref can be a Sha, or a Branch, or a Tag. I added type aliases for those. Note that this does not prevent mixing up of eg, refs and branches at the type level. Since git really doesn't care, except rare cases like git update-ref, or git tag -d, that seems ok for now. There's also a tree-ish, but let's just use Ref for it. A given Sha or Ref may or may not be a tree-ish, depending on the object type, so there seems no point in trying to represent it at the type level.
Diffstat (limited to 'Command/Unused.hs')
-rw-r--r--Command/Unused.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/Command/Unused.hs b/Command/Unused.hs
index 34d8ac232..ccb9c48d8 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -152,12 +152,13 @@ excludeReferenced l = do
(S.fromList l)
where
-- Skip the git-annex branches, and get all other unique refs.
- refs = map last .
+ refs = map Git.Ref .
+ last .
nubBy cmpheads .
filter ourbranches .
map words . lines . L.unpack
cmpheads a b = head a == head b
- ourbranchend = '/' : Annex.Branch.name
+ ourbranchend = '/' : show (Annex.Branch.name)
ourbranches ws = not $ ourbranchend `isSuffixOf` last ws
removewith [] s = return $ S.toList s
removewith (a:as) s
@@ -188,7 +189,7 @@ getKeysReferenced = do
return $ map fst $ catMaybes keypairs
{- List of keys referenced by symlinks in a git ref. -}
-getKeysReferencedInGit :: String -> Annex [Key]
+getKeysReferencedInGit :: Git.Ref -> Annex [Key]
getKeysReferencedInGit ref = do
showAction $ "checking " ++ Git.refDescribe ref
findkeys [] =<< inRepo (LsTree.lsTree ref)