From b4d5c10fb71a0aa938c7dde0b9aaf57d9e793874 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 28 Sep 2011 17:35:47 -0400 Subject: refine new unused code Fixed the laziness space leak, so it runs in 60 mb or so again. Slightly faster due to using Data.Set.difference now, although this also makes it use slightly more memory. Also added display of the refs being checked, and made unused --from also check all refs for things in the remote. --- Git.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Git.hs') diff --git a/Git.hs b/Git.hs index b5464859e..fe2afdcfe 100644 --- a/Git.hs +++ b/Git.hs @@ -20,6 +20,7 @@ module Git ( repoIsHttp, repoIsLocalBare, repoDescribe, + refDescribe, repoLocation, workTree, workTreeFile, @@ -171,6 +172,14 @@ repoDescribe Repo { location = Url url } = show url repoDescribe Repo { location = Dir dir } = dir repoDescribe Repo { location = Unknown } = "UNKNOWN" +{- Converts a fully qualified git ref into a user-visible version -} +refDescribe :: String -> String +refDescribe = remove "refs/heads/" . remove "refs/remotes/" + where + remove prefix s + | prefix `isPrefixOf` s = drop (length prefix) s + | otherwise = s + {- Location of the repo, either as a path or url. -} repoLocation :: Repo -> String repoLocation Repo { location = Url url } = show url -- cgit v1.2.3