]> git.ipfire.org Git - thirdparty/git.git/commit - refs.c
refs: introduce `refs_for_each_include_root_refs()`
authorKarthik Nayak <karthik.188@gmail.com>
Fri, 23 Feb 2024 10:01:10 +0000 (11:01 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 Feb 2024 18:36:27 +0000 (10:36 -0800)
commitd0f00c1ac17bf1e00c2721a90e2bbdb132b5ab6e
treebbf4fe1c4e1805a548a79bc56a0a77aa91b91438
parentf768296cf1ac83d7b3216615da907dddb35fc6cd
refs: introduce `refs_for_each_include_root_refs()`

Introduce a new ref iteration flag `DO_FOR_EACH_INCLUDE_ROOT_REFS`,
which will be used to iterate over regular refs plus pseudorefs and
HEAD.

Refs which fall outside the `refs/` and aren't either pseudorefs or HEAD
are more of a grey area. This is because we don't block the users from
creating such refs but they are not officially supported.

Introduce `refs_for_each_include_root_refs()` which calls
`do_for_each_ref()` with this newly introduced flag.

In `refs/files-backend.c`, introduce a new function
`add_pseudoref_and_head_entries()` to add pseudorefs and HEAD to the
`ref_dir`. We then finally call `add_pseudoref_and_head_entries()`
whenever the `DO_FOR_EACH_INCLUDE_ROOT_REFS` flag is set. Any new ref
backend will also have to implement similar changes on its end.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs.h
refs/files-backend.c
refs/refs-internal.h