Re: [PATCH v2 03/10] refs: add array of ref namespaces
On 2022.07.29 19:29, Derrick Stolee via GitGitGadget wrote:
Show 31 quoted lines
> diff --git a/refs.h b/refs.h
> index 47cb9edbaa8..94e8dedf939 100644
> --- a/refs.h
> +++ b/refs.h
> @@ -2,6 +2,7 @@
> #define REFS_H
>
> #include "cache.h"
> +#include "commit.h"
>
> struct object_id;
> struct ref_store;
> @@ -930,4 +931,49 @@ struct ref_store *get_main_ref_store(struct repository *r);
> struct ref_store *get_submodule_ref_store(const char *submodule);
> struct ref_store *get_worktree_ref_store(const struct worktree *wt);
>
> +/*
> + * Some of the names specified by refs have special meaning to Git.
> + * Organize these namespaces in a comon 'ref_namespaces' array for
> + * reference from multiple places in the codebase.
> + */
> +
> +struct ref_namespace_info {
> + char *ref;
> + enum decoration_type decoration;
> +
> + /*
> + * If 'exact' is true, then we must match the 'ref' exactly.
> + * Otherwise, use a prefix match.
> + *
> + * 'orig_ref' is for internal use. It represents whether thes/orig_ref/ref_updated/ here I think.
Show 34 quoted lines
> + * 'ref' value was replaced from its original literal version.
> + */
> + unsigned exact:1,
> + ref_updated:1;
> +};
> +
> +enum ref_namespace {
> + NAMESPACE_HEAD,
> + NAMESPACE_BRANCHES,
> + NAMESPACE_TAGS,
> + NAMESPACE_REMOTE_REFS,
> + NAMESPACE_STASH,
> + NAMESPACE_REPLACE,
> + NAMESPACE_NOTES,
> + NAMESPACE_PREFETCH,
> + NAMESPACE_REWRITTEN,
> +
> + /* Must be last */
> + NAMESPACE__COUNT
> +};
> +
> +/* See refs.c for the contents of this array. */
> +extern struct ref_namespace_info ref_namespaces[];
> +
> +/*
> + * Some ref namespaces can be modified by config values or environment
> + * variables. Modify a namespace as specified by its ref_namespace key.
> + */
> +void update_ref_namespace(enum ref_namespace namespace, char *ref);
> +
> #endif /* REFS_H */
> --
> gitgitgadget
>