mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
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>
This commit is contained in:
parent
74b50a5881
commit
f6936e62a5
@ -2756,7 +2756,7 @@ static int ref_kind_from_refname(const char *refname)
|
|||||||
return ref_kind[i].kind;
|
return ref_kind[i].kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_pseudoref(get_main_ref_store(the_repository), refname))
|
if (is_root_ref(get_main_ref_store(the_repository), refname))
|
||||||
return FILTER_REFS_PSEUDOREFS;
|
return FILTER_REFS_PSEUDOREFS;
|
||||||
|
|
||||||
return FILTER_REFS_OTHERS;
|
return FILTER_REFS_OTHERS;
|
||||||
|
18
refs.c
18
refs.c
@ -844,7 +844,7 @@ int is_per_worktree_ref(const char *refname)
|
|||||||
starts_with(refname, "refs/rewritten/");
|
starts_with(refname, "refs/rewritten/");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_pseudoref_syntax(const char *refname)
|
static int is_root_ref_syntax(const char *refname)
|
||||||
{
|
{
|
||||||
const char *c;
|
const char *c;
|
||||||
|
|
||||||
@ -853,16 +853,12 @@ static int is_pseudoref_syntax(const char *refname)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* HEAD is not a pseudoref, but it certainly uses the
|
|
||||||
* pseudoref syntax.
|
|
||||||
*/
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_pseudoref(struct ref_store *refs, const char *refname)
|
int is_root_ref(struct ref_store *refs, const char *refname)
|
||||||
{
|
{
|
||||||
static const char *const irregular_pseudorefs[] = {
|
static const char *const irregular_root_refs[] = {
|
||||||
"AUTO_MERGE",
|
"AUTO_MERGE",
|
||||||
"BISECT_EXPECTED_REV",
|
"BISECT_EXPECTED_REV",
|
||||||
"NOTES_MERGE_PARTIAL",
|
"NOTES_MERGE_PARTIAL",
|
||||||
@ -872,7 +868,7 @@ int is_pseudoref(struct ref_store *refs, const char *refname)
|
|||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!is_pseudoref_syntax(refname))
|
if (!is_root_ref_syntax(refname))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ends_with(refname, "_HEAD")) {
|
if (ends_with(refname, "_HEAD")) {
|
||||||
@ -882,8 +878,8 @@ int is_pseudoref(struct ref_store *refs, const char *refname)
|
|||||||
return !is_null_oid(&oid);
|
return !is_null_oid(&oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(irregular_pseudorefs); i++)
|
for (i = 0; i < ARRAY_SIZE(irregular_root_refs); i++)
|
||||||
if (!strcmp(refname, irregular_pseudorefs[i])) {
|
if (!strcmp(refname, irregular_root_refs[i])) {
|
||||||
refs_resolve_ref_unsafe(refs, refname,
|
refs_resolve_ref_unsafe(refs, refname,
|
||||||
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
|
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
|
||||||
&oid, NULL);
|
&oid, NULL);
|
||||||
@ -902,7 +898,7 @@ int is_headref(struct ref_store *refs, const char *refname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int is_current_worktree_ref(const char *ref) {
|
static int is_current_worktree_ref(const char *ref) {
|
||||||
return is_pseudoref_syntax(ref) || is_per_worktree_ref(ref);
|
return is_root_ref_syntax(ref) || is_per_worktree_ref(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ref_worktree_type parse_worktree_ref(const char *maybe_worktree_ref,
|
enum ref_worktree_type parse_worktree_ref(const char *maybe_worktree_ref,
|
||||||
|
28
refs.h
28
refs.h
@ -1051,7 +1051,33 @@ extern struct ref_namespace_info ref_namespace[NAMESPACE__COUNT];
|
|||||||
*/
|
*/
|
||||||
void update_ref_namespace(enum ref_namespace namespace, char *ref);
|
void update_ref_namespace(enum ref_namespace namespace, char *ref);
|
||||||
|
|
||||||
int is_pseudoref(struct ref_store *refs, const char *refname);
|
/*
|
||||||
|
* Check whether the reference is an existing root reference.
|
||||||
|
*
|
||||||
|
* A root ref is a reference that lives in the root of the reference hierarchy.
|
||||||
|
* These references must conform to special syntax:
|
||||||
|
*
|
||||||
|
* - Their name must be all-uppercase or underscores ("_").
|
||||||
|
*
|
||||||
|
* - Their name must end with "_HEAD".
|
||||||
|
*
|
||||||
|
* - Their name may not contain a slash.
|
||||||
|
*
|
||||||
|
* There is a special set of irregular root refs that exist due to historic
|
||||||
|
* reasons, only. This list shall not be expanded in the future:
|
||||||
|
*
|
||||||
|
* - AUTO_MERGE
|
||||||
|
*
|
||||||
|
* - BISECT_EXPECTED_REV
|
||||||
|
*
|
||||||
|
* - NOTES_MERGE_PARTIAL
|
||||||
|
*
|
||||||
|
* - NOTES_MERGE_REF
|
||||||
|
*
|
||||||
|
* - MERGE_AUTOSTASH
|
||||||
|
*/
|
||||||
|
int is_root_ref(struct ref_store *refs, const char *refname);
|
||||||
|
|
||||||
int is_headref(struct ref_store *refs, const char *refname);
|
int is_headref(struct ref_store *refs, const char *refname);
|
||||||
|
|
||||||
#endif /* REFS_H */
|
#endif /* REFS_H */
|
||||||
|
@ -351,7 +351,7 @@ static void add_pseudoref_and_head_entries(struct ref_store *ref_store,
|
|||||||
strbuf_addstr(&refname, de->d_name);
|
strbuf_addstr(&refname, de->d_name);
|
||||||
|
|
||||||
dtype = get_dtype(de, &path, 1);
|
dtype = get_dtype(de, &path, 1);
|
||||||
if (dtype == DT_REG && (is_pseudoref(ref_store, de->d_name) ||
|
if (dtype == DT_REG && (is_root_ref(ref_store, de->d_name) ||
|
||||||
is_headref(ref_store, de->d_name)))
|
is_headref(ref_store, de->d_name)))
|
||||||
loose_fill_ref_dir_regular_file(refs, refname.buf, dir);
|
loose_fill_ref_dir_regular_file(refs, refname.buf, dir);
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
|
|||||||
*/
|
*/
|
||||||
if (!starts_with(iter->ref.refname, "refs/") &&
|
if (!starts_with(iter->ref.refname, "refs/") &&
|
||||||
!(iter->flags & DO_FOR_EACH_INCLUDE_ROOT_REFS &&
|
!(iter->flags & DO_FOR_EACH_INCLUDE_ROOT_REFS &&
|
||||||
(is_pseudoref(&iter->refs->base, iter->ref.refname) ||
|
(is_root_ref(&iter->refs->base, iter->ref.refname) ||
|
||||||
is_headref(&iter->refs->base, iter->ref.refname)))) {
|
is_headref(&iter->refs->base, iter->ref.refname)))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user