]> git.ipfire.org Git - thirdparty/git.git/commit
refs: complete list of special refs
authorPatrick Steinhardt <ps@pks.im>
Thu, 14 Dec 2023 13:37:06 +0000 (14:37 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Dec 2023 17:25:27 +0000 (09:25 -0800)
commit70c70de616c306cd4bb7c70426e394d08f929dff
treeb68dac59448f2760c35210a73efd7bb8a28e7d42
parent668cdc043fe6f6d1fa2bf2b3f3c2375a20819e77
refs: complete list of special refs

We have some references that are more special than others. The reason
for them being special is that they either do not follow the usual
format of references, or that they are written to the filesystem
directly by the respective owning subsystem and thus circumvent the
reference backend.

This works perfectly fine right now because the reffiles backend will
know how to read those refs just fine. But with the prospect of gaining
a new reference backend implementation we need to be a lot more careful
here:

  - We need to make sure that we are consistent about how those refs are
    written. They must either always be written via the filesystem, or
    they must always be written via the reference backend. Any mixture
    will lead to inconsistent state.

  - We need to make sure that such special refs are always handled
    specially when reading them.

We're already mostly good with regard to the first item, except for
`BISECT_EXPECTED_REV` which will be addressed in a subsequent commit.
But the current list of special refs is missing some refs that really
should be treated specially. Right now, we only treat `FETCH_HEAD` and
`MERGE_HEAD` specially here.

Introduce a new function `is_special_ref()` that contains all current
instances of special refs to fix the reading path.

Note that this is only a temporary measure where we record and rectify
the current state. Ideally, the list of special refs should in the end
only contain `FETCH_HEAD` and `MERGE_HEAD` again because they both may
reference multiple objects and can contain annotations, so they indeed
are special.

Based-on-patch-by: Han-Wen Nienhuys <hanwenn@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c