Project.pm: tolerate a peculiar HEAD
Previously the get_HEAD function would die if HEAD was not set
to a symbolic ref to something under the refs/heads namespace.
With the advent of reluctant accomodation for linked working
trees and perhaps even non-bare Girocco repositories, it's
quite plausible that a bizarre HEAD could be encountered.
Do not die when an unpalatable HEAD pops up.
Instead return a descriptive value surrounded by square
brackets ('[' and ']') for the result of get_HEAD.
A missing or invalid HEAD will still cause the code to dia (as it
should since the repository would not be usable in that case).
Since Git will reject any ref name with a left square bracket '['
character in it, there's no danger of such a "descriptive value"
ending up being somehow set as the project's HEAD.
The web UI will even show such a value provided there are no other
ref/heads/... refs in the repository as a side-effect of not
wanting to fail to show the HEAD symref of an empty repository.
The project will even be editable in such a state since the
update code will not try to set the HEAD if it's unchanged.
Although if there are any existing refs/heads/... refs editing the
project and saving the changes will always reattach the HEAD since
a "descriptive value" will only be a choice if there are no heads.
With this change repositories having an unsavory HEAD can still
be manipulated by Girocco without issues.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>