refs: rename `is_pseudoref()` to `is_root_ref()`
Rename `is_pseudoref()` to `is_root_ref()` to adapt to the newly defined terminology in our gitglossary(7). Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 15, 2024 at 08:50 UTC
f6936e62a50e8bc9e268f3396618d33e88f4df7e
5 files changed
+37
-15
ref-filter.c
+1
-1
@@ -2756,7 +2756,7 @@ static int ref_kind_from_refname(const char *refname)
2756
return ref_kind[i].kind;
2757
}
2758
2759
- if (is_pseudoref(get_main_ref_store(the_repository), refname))
2759
+ if (is_root_ref(get_main_ref_store(the_repository), refname))
2760
return FILTER_REFS_PSEUDOREFS;
2761
2762
return FILTER_REFS_OTHERS;
refs.c
+7
-11
@@ -844,7 +844,7 @@ int is_per_worktree_ref(const char *refname)
844
starts_with(refname, "refs/rewritten/");
845
}
846
847
-static int is_pseudoref_syntax(const char *refname)
847
+static int is_root_ref_syntax(const char *refname)
848
{
849
const char *c;
850
@@ -853,16 +853,12 @@ static int is_pseudoref_syntax(const char *refname)
853
return 0;
854
}
855
856
- /*
857
- * HEAD is not a pseudoref, but it certainly uses the
858
- * pseudoref syntax.
859
- */
856
return 1;
857
}
858
863
-int is_pseudoref(struct ref_store *refs, const char *refname)
859
+int is_root_ref(struct ref_store *refs, const char *refname)
860
{
865
- static const char *const irregular_pseudorefs[] = {
861
+ static const char *const irregular_root_refs[] = {
862
"AUTO_MERGE",
863
"BISECT_EXPECTED_REV",
864
"NOTES_MERGE_PARTIAL",
@@ -872,7 +868,7 @@ int is_pseudoref(struct ref_store *refs, const char *refname)
868
struct object_id oid;
869
size_t i;
870
875
- if (!is_pseudoref_syntax(refname))
871
+ if (!is_root_ref_syntax(refname))
872
return 0;
873
874
if (ends_with(refname, "_HEAD")) {
@@ -882,8 +878,8 @@ int is_pseudoref(struct ref_store *refs, const char *refname)
878
return !is_null_oid(&oid);
879
}
880
885
- for (i = 0; i < ARRAY_SIZE(irregular_pseudorefs); i++)
886
- if (!strcmp(refname, irregular_pseudorefs[i])) {
881
+ for (i = 0; i < ARRAY_SIZE(irregular_root_refs); i++)
882
+ if (!strcmp(refname, irregular_root_refs[i])) {
883
refs_resolve_ref_unsafe(refs, refname,
884
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
885
&oid, NULL);
@@ -902,7 +898,7 @@ int is_headref(struct ref_store *refs, const char *refname)
898
}
899
900
static int is_current_worktree_ref(const char *ref) {
905
- return is_pseudoref_syntax(ref) || is_per_worktree_ref(ref);
901
+ return is_root_ref_syntax(ref) || is_per_worktree_ref(ref);
902
}
903
904
enum ref_worktree_type parse_worktree_ref(const char *maybe_worktree_ref,
refs.h
+27
-1
@@ -1051,7 +1051,33 @@ extern struct ref_namespace_info ref_namespace[NAMESPACE__COUNT];
1051
*/
1052
void update_ref_namespace(enum ref_namespace namespace, char *ref);
1053
1054
-int is_pseudoref(struct ref_store *refs, const char *refname);
1054
+/*
1055
+ * Check whether the reference is an existing root reference.
1056
+ *
1057
+ * A root ref is a reference that lives in the root of the reference hierarchy.
1058
+ * These references must conform to special syntax:
1059
+ *
1060
+ * - Their name must be all-uppercase or underscores ("_").
1061
+ *
1062
+ * - Their name must end with "_HEAD".
1063
+ *
1064
+ * - Their name may not contain a slash.
1065
+ *
1066
+ * There is a special set of irregular root refs that exist due to historic
1067
+ * reasons, only. This list shall not be expanded in the future:
1068
+ *
1069
+ * - AUTO_MERGE
1070
+ *
1071
+ * - BISECT_EXPECTED_REV
1072
+ *
1073
+ * - NOTES_MERGE_PARTIAL
1074
+ *
1075
+ * - NOTES_MERGE_REF
1076
+ *
1077
+ * - MERGE_AUTOSTASH
1078
+ */
1079
+int is_root_ref(struct ref_store *refs, const char *refname);
1080
+
1081
int is_headref(struct ref_store *refs, const char *refname);
1082
1083
#endif /* REFS_H */
refs/files-backend.c
+1
-1
@@ -351,7 +351,7 @@ static void add_pseudoref_and_head_entries(struct ref_store *ref_store,
351
strbuf_addstr(&refname, de->d_name);
352
353
dtype = get_dtype(de, &path, 1);
354
- if (dtype == DT_REG && (is_pseudoref(ref_store, de->d_name) ||
354
+ if (dtype == DT_REG && (is_root_ref(ref_store, de->d_name) ||
355
is_headref(ref_store, de->d_name)))
356
loose_fill_ref_dir_regular_file(refs, refname.buf, dir);
357
refs/reftable-backend.c
+1
-1
@@ -356,7 +356,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
356
*/
357
if (!starts_with(iter->ref.refname, "refs/") &&
358
!(iter->flags & DO_FOR_EACH_INCLUDE_ROOT_REFS &&
359
- (is_pseudoref(&iter->refs->base, iter->ref.refname) ||
359
+ (is_root_ref(&iter->refs->base, iter->ref.refname) ||
360
is_headref(&iter->refs->base, iter->ref.refname)))) {
361
continue;
362
}