download_strategy: fix Git repo updating.

Git repositories should always be updated when the ref is a branch.
They should be also updated if no ref was specified or if the ref isn’t
present. This stops the repo being updated if we’re building a specific
revision and it is present. Additionally, this stops the update barfing
on repositories where we’re using a revision and there is no upstream
`master` branch.

Closes #29218.