Replace git rev-list --quiet with git cat-file -e for checking if a
revision exists. This changes the operation from O(commits) to O(1).
Benchmarks from a large monorepo:
- git rev-list --quiet <sha>: 5150ms
- git cat-file -e <sha>: 4ms
Both commands have the same semantics: return success if the revision
exists in the local repo, failure otherwise.
From the `pre-push.sample` file:
> Information about the commits which are being pushed is supplied as
> lines to the standard input in the form:
>
> <local ref> <local sha1> <remote ref> <remote sha1>
When `<local ref>` is not simply a branch name, but a more general
ref (see git-rev-parse(1)), it could contain whitespace, and that
breaks the split() call that expected only 3 spaces in the line.
Changed to use `rsplit(maxsplit=3)` since only the <local ref> is
likely to have embedded whitespace.
Added a new test case for the same.