Avoid segfault with 'git branch' when the HEAD is detached