`expected_old_oid` does not support zero object ID
Problem
According to the documentation, field expected_old_oid
should support zero object ID (like 0000000000000000000000000000000000000000
for SHA1 repositories).
If set, it must either contain a valid, full object ID or the zero object ID in case the branch should be created. Otherwise, this RPC will return an error.
But it currently returns 3:cannot resolve expected old object ID: reference not found
when expected_old_oid is set to 0000000000000000000000000000000000000000
.
Research
I believe it's related to git rev-parse
behavior for zero object IDs.
This line of code modifies the reference value before providing it to rev-parse
from 0000000000000000000000000000000000000000
to 0000000000000000000000000000000000000000^{object}
# for existing SHA hash
git rev-parse a94c07515d8320d4f9e395c703f3ef0e10df0f43^{object}
> a94c07515d8320d4f9e395c703f3ef0e10df0f43
# it returns a fatal error
git rev-parse 0000000000000000000000000000000000000000^{object}
> 0000000000000000000000000000000000000000^{object}
> fatal: ambiguous argument '0000000000000000000000000000000000000000^{object}': unknown revision or path not in the working tree.
# however, it works without ^{object}
git rev-parse 0000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000