Use git describe when needed

With the recent versions of git, "git branch" does not print "(no
branch)" anymore if the head is detached. Instead, it provides more
details.

However, we can detect this is a detached head because the details are
always surrounded by parenthesis.

Also add the "--all" parameter to "git describe" the most human-readable
name for detached head.
Use [[ ]] instead of [ ]

Test the conditions using bash, instead of spawning the '[' program.