git state to update repo where rev = branch name

I have discovered that the fix for #7370 introduced another problem. When rev = a branch name, it's great that it doesn't touch anything that it's not supposed to now, but it also doesn't update when it is supposed to! Sorry - my bad.

I've looked into this more closely, and tried to think of the various use-case scenarios that we need to support in this section of code so as to make sure we have everything covered. Here's what I came up with:

1. A hash was specified, we're not on a branch and there was no updates.
2. A hash was specified, we're not on a branch and there was updates.
3. A hash was specified, we're on a branch and there was no updates.
4. A hash was specified, we're on a branch and there was updates.
5. A branch was specified, we're not on a branch and there was no updates.
6. A branch was specified, we're not on a branch and there was updates.
7. A branch was specified, we're on a branch and there was no updates.
8. A branch was specified, we're on a branch and there was updates.

I think the attached pull request will now work in 7 of those 8 scenarios, but scenario 5 will still fail.

If we specify a branch but are not on a branch, but we have the correct hash, we don't want to touch the code and then say we touched nothing (issue #7370). Unfortunately, since we're not on a branch, we end up with:

```
current_rev = <some hash>
remote_rev = None
branch = ""
rev = 'master'
```

So current_rev won't match rev or remote_rev, and it will go through all the git magic that nukes any local post-pull changes that there might be. Perhaps someone smarter than me can find an elegant way to solve this, although I imagine that this scenario is quite unlikely - it's likely always been broken and nobody has complained.

In the meantime however, the pull request does solve more common scenarios such as number 8 (which I broke). Thanks.