1{- git reflog interface 2 - 3 - Copyright 2013 Joey Hess <id@joeyh.name> 4 - 5 - Licensed under the GNU AGPL version 3 or higher. 6 -} 7 8module Git.RefLog where 9 10import Common 11import Git 12import Git.Command 13import Git.Sha 14 15import qualified Data.ByteString as S 16import qualified Data.ByteString.Char8 as S8 17 18{- Gets the reflog for a given branch. -} 19get :: Branch -> Repo -> IO [Sha] 20get b = getMulti [b] 21 22{- Gets reflogs for multiple branches. -} 23getMulti :: [Branch] -> Repo -> IO [Sha] 24getMulti bs = get' (map (Param . fromRef) bs) 25 26get' :: [CommandParam] -> Repo -> IO [Sha] 27get' ps = mapMaybe (extractSha . S.copy) . S8.lines <$$> pipeReadStrict ps' 28 where 29 ps' = catMaybes 30 [ Just $ Param "log" 31 , Just $ Param "-g" 32 , Just $ Param "--format=%H" 33 ] ++ ps 34