Message ID | 20240119142705.139374-2-karthik.188@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | for-each-ref: print all refs on empty string pattern | expand |
Karthik Nayak <karthik.188@gmail.com> writes: > The `is_pseudoref_syntax()` function is static, since it is only used > within `refs.c`. In the following commit, we will use this function to > provide an utility to add pseudorefs to the loose refs cache. So let's > expose this function via `refs.h`. > > Signed-off-by: Karthik Nayak <karthik.188@gmail.com> > --- > refs.c | 2 +- > refs.h | 6 ++++++ > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/refs.c b/refs.c > index 2f58a3460a..5999605230 100644 > --- a/refs.c > +++ b/refs.c > @@ -827,7 +827,7 @@ int is_per_worktree_ref(const char *refname) > starts_with(refname, "refs/rewritten/"); > } > > -static int is_pseudoref_syntax(const char *refname) > +int is_pseudoref_syntax(const char *refname) > { > const char *c; > > diff --git a/refs.h b/refs.h > index ff113bb12a..f1bbad83fb 100644 > --- a/refs.h > +++ b/refs.h > @@ -846,6 +846,12 @@ const char **hidden_refs_to_excludes(const struct strvec *hide_refs); > /* Is this a per-worktree ref living in the refs/ namespace? */ > int is_per_worktree_ref(const char *refname); > > +/* > + * Check whether a refname matches the pseudoref syntax. This is a surface > + * level check and can present false positives. > + */ What does "false positive" mean in this context? is_pseudoref_syntax("FOO_HEAD") says "true", and then if it is "false positive", that would mean "FOO_HEAD" is not a pseudo ref, right? What can a caller of this function do to deal with a false positive? Or do you mean "FOO_HEAD" is still a pseudo ref, but it may not currently exist? That is different from "false positive". As the check is about "does it match the pseudoref syntax?", I would understand if what you wanted to say was something like: This only checks the syntax, and such a pseudoref may not currently exist in the repository---for that you'd need to call read_ref_full() or other ref API functions. Puzzled... Thanks.
On Fri, Jan 19, 2024 at 9:37 PM Junio C Hamano <gitster@pobox.com> wrote: > > > > +/* > > + * Check whether a refname matches the pseudoref syntax. This is a surface > > + * level check and can present false positives. > > + */ > > What does "false positive" mean in this context? > > is_pseudoref_syntax("FOO_HEAD") says "true", and then if it is > "false positive", that would mean "FOO_HEAD" is not a pseudo ref, > right? What can a caller of this function do to deal with a false > positive? > > Or do you mean "FOO_HEAD" is still a pseudo ref, but it may not > currently exist? That is different from "false positive". > Yes, I think this is what I wanted to say and what you say below is what I'll change it to. > As the check is about "does it match the pseudoref syntax?", I would > understand if what you wanted to say was something like: This only > checks the syntax, and such a pseudoref may not currently exist in > the repository---for that you'd need to call read_ref_full() or > other ref API functions. > > Puzzled... > > Thanks. Thanks!
diff --git a/refs.c b/refs.c index 2f58a3460a..5999605230 100644 --- a/refs.c +++ b/refs.c @@ -827,7 +827,7 @@ int is_per_worktree_ref(const char *refname) starts_with(refname, "refs/rewritten/"); } -static int is_pseudoref_syntax(const char *refname) +int is_pseudoref_syntax(const char *refname) { const char *c; diff --git a/refs.h b/refs.h index ff113bb12a..f1bbad83fb 100644 --- a/refs.h +++ b/refs.h @@ -846,6 +846,12 @@ const char **hidden_refs_to_excludes(const struct strvec *hide_refs); /* Is this a per-worktree ref living in the refs/ namespace? */ int is_per_worktree_ref(const char *refname); +/* + * Check whether a refname matches the pseudoref syntax. This is a surface + * level check and can present false positives. + */ +int is_pseudoref_syntax(const char *refname); + /* Describes how a refname relates to worktrees */ enum ref_worktree_type { REF_WORKTREE_CURRENT, /* implicitly per worktree, eg. HEAD or
The `is_pseudoref_syntax()` function is static, since it is only used within `refs.c`. In the following commit, we will use this function to provide an utility to add pseudorefs to the loose refs cache. So let's expose this function via `refs.h`. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> --- refs.c | 2 +- refs.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-)