Make git rev-parse check fail if SHA not found

This reinstates the change in 51d18a495e68b1812a58e3a2f03eeee1cfc34bf5.

That change was first broken by 091a5515fefc6ba69be2507aaace5e5d685a1618
(by introducing a space, which breaks the `<rev>^{<type>}` syntax being
used, see `git rev-parse` documentation) ... and then fully removed by
ef48008bbc7e641edb2f4f304f749d5378c3de2e. The commit message in the
latter commit does not suggest an intent or a reason to revert the
51d18a495e68b1812a58e3a2f03eeee1cfc34bf5 change, so it was probably just
trying to resolve the immediate problem that the git rev-parse call was
broken.
Merge pull request #11476 from gthb/fix-rev-parse-check-to-fail-if-sha-not-found

Make git rev-parse check fail if SHA not found