refs: add array of ref namespaces
Git interprets different meanings to different refs based on their names. Some meanings are cosmetic, like how refs in 'refs/remotes/*' are colored differently from refs in 'refs/heads/*'. Others are more critical, such as how replace refs are interpreted. Before making behavior changes based on ref namespaces, collect all known ref namespaces into a array of ref_namespace_info structs. This array is indexed by the new ref_namespace enum for quick access. As of this change, this array is purely documentation. Future changes will add dependencies on this array. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
5797b13919
commit
b9342b3fd6
46
refs.h
46
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_namespace' 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.
|
||||
*
|
||||
* 'ref_updated' is for internal use. It represents whether the
|
||||
* '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_namespace[NAMESPACE__COUNT];
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
|
Reference in New Issue
Block a user