kennethreitz/legit — pull request #57 by offbyone (2012-04-09 04:25:24+00:00)
Title: Handle detached head in legit branches

Currently, if you call 'legit branches' in a git repo that has a detached head, you get this:

Traceback (most recent call last):
File "/Users/offline/virtualenv/legit/bin/legit", line 8, in
load_entry_point('legit==0.1.0', 'console_scripts', 'legit')()
File "/Users/offline/projects/legit/legit/cli.py", line 45, in main
cmd_map.get(arg).__call__(args)
File "/Users/offline/projects/legit/legit/cli.py", line 337, in cmd_branches
display_available_branches()
File "/Users/offline/projects/legit/legit/cli.py", line 444, in display_available_branches
marker = '*' if (branch.name == repo.head.ref.name) else ' '
File "/Users/offline/virtualenv/legit/lib/python2.7/site-packages/GitPython-0.3.2.RC1-py2.7.egg/git/refs/symbolic.py", line 244, in _get_reference
raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
TypeError: HEAD is a detached symbolic reference as it points to '6ad8bad03bb47b65c6c633562a8cae082844b9cf'

Obviously, suboptimal.

That's fixed by this pull request.