refactor and check for a detached HEAD

This commit is contained in:
Joey Hess 2011-12-31 03:38:58 -04:00
parent 8a33573caf
commit a2ec2d3760
2 changed files with 11 additions and 6 deletions

View file

@ -14,6 +14,14 @@ import Git
import Git.Sha
import Git.Command
{- The currently checked out branch. -}
current :: Repo -> IO (Maybe Git.Ref)
current r = parse <$> pipeRead [Param "symbolic-ref", Param "HEAD"] r
where
parse v
| L.null v = Nothing
| otherwise = Just $ Git.Ref $ firstLine $ L.unpack v
{- Checks if the second branch has any commits not present on the first
- branch. -}
changed :: Branch -> Branch -> Repo -> IO Bool