summaryrefslogtreecommitdiffstats
path: root/refs.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-15 08:50:56 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-15 16:30:52 +0200
commit31951c22489dc4238ef881478a896a460531b722 (patch)
tree3188677c2ef7fc6a7c243e1b4ef054e08fd91acd /refs.h
parentrefs: do not check ref existence in `is_root_ref()` (diff)
downloadgit-31951c22489dc4238ef881478a896a460531b722.tar.xz
git-31951c22489dc4238ef881478a896a460531b722.zip
refs: classify HEAD as a root ref
Root refs are those refs that live in the root of the ref hierarchy. Our old and venerable "HEAD" reference falls into this category, but we don't yet classify it as such in `is_root_ref()`. Adapt the function to also treat "HEAD" as a root ref. This change is safe to do for all current callers: - `ref_kind_from_refname()` already handles "HEAD" explicitly before calling `is_root_ref()`. - The "files" and "reftable" backends explicitly call both `is_root_ref()` and `is_headref()` together. This also aligns behaviour or `is_root_ref()` and `is_headref()` such that we stop checking for ref existence. This changes semantics for our backends: - In the reftable backend we already know that the ref must exist because `is_headref()` is called as part of the ref iterator. The existence check is thus redundant, and the change is safe to do. - In the files backend we use it when populating root refs, where we would skip adding the "HEAD" file if it was not possible to resolve it. The new behaviour is to instead mark "HEAD" as broken, which will cause us to emit warnings in various places. As there are no callers of `is_headref()` left afer the refactoring, we can absorb it completely into `is_root_ref()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/refs.h b/refs.h
index 8a574a22c7..8489b45265 100644
--- a/refs.h
+++ b/refs.h
@@ -1060,7 +1060,8 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref);
*
* - Their name must be all-uppercase or underscores ("_").
*
- * - Their name must end with "_HEAD".
+ * - Their name must end with "_HEAD". As a special rule, "HEAD" is a root
+ * ref, as well.
*
* - Their name may not contain a slash.
*
@@ -1079,6 +1080,4 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref);
*/
int is_root_ref(const char *refname);
-int is_headref(struct ref_store *refs, const char *refname);
-
#endif /* REFS_H */