Skip to content

Commit f6936e6

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 74b50a5 commit f6936e6

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2756,7 +2756,7 @@ static int ref_kind_from_refname(const char *refname)
27562756
return ref_kind[i].kind;
27572757
}
27582758

2759-
if (is_pseudoref(get_main_ref_store(the_repository), refname))
2759+
if (is_root_ref(get_main_ref_store(the_repository), refname))
27602760
return FILTER_REFS_PSEUDOREFS;
27612761

27622762
return FILTER_REFS_OTHERS;

refs.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ int is_per_worktree_ref(const char *refname)
844844
starts_with(refname, "refs/rewritten/");
845845
}
846846

847-
static int is_pseudoref_syntax(const char *refname)
847+
static int is_root_ref_syntax(const char *refname)
848848
{
849849
const char *c;
850850

@@ -853,16 +853,12 @@ static int is_pseudoref_syntax(const char *refname)
853853
return 0;
854854
}
855855

856-
/*
857-
* HEAD is not a pseudoref, but it certainly uses the
858-
* pseudoref syntax.
859-
*/
860856
return 1;
861857
}
862858

863-
int is_pseudoref(struct ref_store *refs, const char *refname)
859+
int is_root_ref(struct ref_store *refs, const char *refname)
864860
{
865-
static const char *const irregular_pseudorefs[] = {
861+
static const char *const irregular_root_refs[] = {
866862
"AUTO_MERGE",
867863
"BISECT_EXPECTED_REV",
868864
"NOTES_MERGE_PARTIAL",
@@ -872,7 +868,7 @@ int is_pseudoref(struct ref_store *refs, const char *refname)
872868
struct object_id oid;
873869
size_t i;
874870

875-
if (!is_pseudoref_syntax(refname))
871+
if (!is_root_ref_syntax(refname))
876872
return 0;
877873

878874
if (ends_with(refname, "_HEAD")) {
@@ -882,8 +878,8 @@ int is_pseudoref(struct ref_store *refs, const char *refname)
882878
return !is_null_oid(&oid);
883879
}
884880

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])) {
887883
refs_resolve_ref_unsafe(refs, refname,
888884
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
889885
&oid, NULL);
@@ -902,7 +898,7 @@ int is_headref(struct ref_store *refs, const char *refname)
902898
}
903899

904900
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);
906902
}
907903

908904
enum ref_worktree_type parse_worktree_ref(const char *maybe_worktree_ref,

refs.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,33 @@ extern struct ref_namespace_info ref_namespace[NAMESPACE__COUNT];
10511051
*/
10521052
void update_ref_namespace(enum ref_namespace namespace, char *ref);
10531053

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+
10551081
int is_headref(struct ref_store *refs, const char *refname);
10561082

10571083
#endif /* REFS_H */

refs/files-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static void add_pseudoref_and_head_entries(struct ref_store *ref_store,
351351
strbuf_addstr(&refname, de->d_name);
352352

353353
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) ||
355355
is_headref(ref_store, de->d_name)))
356356
loose_fill_ref_dir_regular_file(refs, refname.buf, dir);
357357

refs/reftable-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
356356
*/
357357
if (!starts_with(iter->ref.refname, "refs/") &&
358358
!(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) ||
360360
is_headref(&iter->refs->base, iter->ref.refname)))) {
361361
continue;
362362
}

0 commit comments

Comments
 (0)