Fix exception when on a detached head.

When there is no branch name (e.g. during a rebase, or when I run `git
checkout master~1`) then the prompt construction was broken.