Re: [PATCH v12 2/8] refs: atomically record overwritten ref in update_symref
"Bence Ferdinandy" <ferdinandy.bence@ttk.elte.hu> writes:
Show 16 quoted lines
>>
>>> } + if (referent) + refs_read_symbolic_ref(refs, ref,
>>> referent);
>
>
> So I've been working on detecting a detached remote/HEAD, and it seems that
> "refs_read_symbolic_ref" behaves differently for the files and the reftables
> backend. These are the exit codes in the various states:
>
>
> reftables files
> detached -1 1
> doesn't exist -1 -1
>
> I would assume this is a bug in reftables? At least the behaviour of files is
> more useful for this case ...
Interesting. Patrick, comments?
Show 30 quoted lines
> This now works fine with the files backend:
>
> if (referent && refs_read_symbolic_ref(refs, ref, referent) == 1) {
> struct object_id oid;
> refs_read_ref(refs, ref, &oid);
> strbuf_addstr(referent, oid_to_hex(&oid));
> ret = -1;
> }
>
> And 4/8 can now also detect being detached, by checking the return value using
> the test you suggested, but this fails for reftables. Just in case it might be
> something about the test not being correct:
>
>
> test_expect_success 'set-head --auto to update a non symbolic ref' '
> (
> cd test &&
> git update-ref --no-deref -d refs/remotes/origin/HEAD &&
> git update-ref refs/remotes/origin/HEAD HEAD &&
> HEAD=$(git log --pretty="%H") &&
> git remote set-head --auto origin >output &&
> echo "${SQ}origin/HEAD${SQ} was detached at ${SQ}${HEAD}${SQ} and now points to ${SQ}main${SQ}" >expect &&
> test_cmp expect output
> )
> '
>
> Should I fix the reftables problem or should I mark the above test as a known
> breakage? Can that be done for just reftables somehow? The only problem
> reftables suffers this way is to incorrectly report "creation" instead of
> correctly saying it was a detached head.