Correctly handle detached head for 'latest' on latest Git versions

Newer versions of Git (I'm not sure as of what version) will output the following for `git branch -a` while in a detached HEAD state:

```
$ git branch -a
* (detached from 4689c51)                                             
  master                                                              
  remotes/origin/HEAD -> origin/master
```

The first line is different than what is expected from previous Git version: "(no branch)". This patch uses rev-parse, which should work with most existing Git versions and will hopefully be immune to this problem in the future.

This patch also gets rid of "origin/HEAD", which is not a valid (and does throw an error in newer Git versions); origin/master points to the tip of master on origin, which seems to be what was desired.