Skip to content

Ensure GIT_BRANCH non-empty when not on a branch

Angus Lepper requested to merge git_branch into master

If HEAD is detached e.g. during git bisect, GIT_BRANCH ends up empty, which causes an error at runtime. This change grabs the description from git branch, which is either the branch name or something like (HEAD detached at <hash>) on recent versions or (no branch) in older versions. Works with BSD and GNU sed, and git >= 1.0.0b (at least) although detached HEAD only introduced in 1.5.0.

Merge request reports