make git_prompt_info aware of detached HEAD and tags

This is a slightly modified and better version of an earlier pull request (#1033).

This patch updates the git_prompt_info function to first look at whether or not the repository is in a detached HEAD state and, if so, to attempt to determine if a tag is currently checked out.

I think this is a useful addition, since currently when a repository is in this state, git_prompt_info returns a blank string, which can lead users to falsely believe they are not in a git repository at all.

Please tell me if I have broken any style or scripting guidelines and I will make corrections. Thanks for all your hard work.