Thread (11 messages) flat view 11 messages, 4 authors, 2018-05-10

Re: [PATCH] refs: handle null-oid for pseudorefs

From: Michael Haggerty <hidden>
Date: 2018-05-07 07:39:14

On 05/06/2018 03:35 PM, Martin Ågren wrote:
According to the documentation on `git update-ref`, it is possible to
"specify 40 '0' or an empty string as <oldvalue> to make sure that the
ref you are creating does not exist." But in the code for pseudorefs, we
do not implement this. If we fail to read the old ref, we immediately
die. A failure to read would actually be a good thing if we have been
given the null-oid.

With the null-oid, allow -- and even require -- the ref-reading to fail.
This implements the "make sure that the ref ... does not exist" part of
the documentation.

Since we have a `strbuf err` for collecting errors, let's use it and
signal an error to the caller instead of dying hard.

Reported-by: Rafael Ascensão <redacted>
Helped-by: Rafael Ascensão [off-list ref]
Signed-off-by: Martin Ågren <redacted>
Thanks for the patch. This looks good to me. But it it seems that the
test coverage related to pseudorefs is still not great. Ideally, all of
the following combinations should be tested:

Pre-update value   | ref-update old OID   | Expected result
-------------------|----------------------|----------------
missing            | missing              | accept *
missing            | value                | reject
set                | missing              | reject *
set                | correct value        | accept
set                | wrong value          | reject

I think your test only covers the lines with asterisks. Are the other
scenarios already covered by other tests? If not, how about adding them?
That would give us confidence that the new code works in all circumstances.

Michael
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help