Re: [PATCH 1/5] refs: expose `is_pseudoref_syntax()`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 19, 2024, 20:37 UTC
- Message-ID
- <xmqq34utjbz9.fsf@gitster.g>
- In-Reply-To
- <20240119142705.139374-2-karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 36 quoted lines
> 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.