unused: --used-refspec can now be configured to look at refs in the reflog. This provides a way to not consider old versions of files to be unused after they have reached a specified age, when the old refs in the reflog expire.

May be slow.
This commit is contained in:
Joey Hess 2015-07-07 17:13:50 -04:00
parent a51b98cdd5
commit b11d2f5a8a
7 changed files with 40 additions and 13 deletions

View file

@ -14,14 +14,18 @@ import Git.Sha
{- Gets the reflog for a given branch. -}
get :: Branch -> Repo -> IO [Sha]
get = get' []
get b = get' [] (Just b)
get' :: [CommandParam] -> Branch -> Repo -> IO [Sha]
{- Gets all reflogs for all branches. -}
getAll :: Repo -> IO [Sha]
getAll = get' [Param "--all"] Nothing
get' :: [CommandParam] -> Maybe Branch -> Repo -> IO [Sha]
get' ps b = mapMaybe extractSha . lines <$$> pipeReadStrict ps'
where
ps' =
[ Param "log"
, Param "-g"
, Param "--format=%H"
, Param (fromRef b)
ps' = catMaybes
[ Just $ Param "log"
, Just $ Param "-g"
, Just $ Param "--format=%H"
, Param . fromRef <$> b
] ++ ps