remove grep and use rev-parse
expect head instead of an empty string branches

If the branch is detached, git rev-parse will return HEAD, instead of an
empty string.
Dont set upstream if ref is HEAD

If the ref is HEAD, the we should be in a detached HEAD, and thus don't
have a remote, so there is no point in setting this.
Merge pull request #14774 from gtmanfred/remove-grep

Remove grep from git.current_branch