Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/refs.h
diff options
context:
space:
mode:
authorDerrick Stolee <derrickstolee@github.com>2022-08-05 20:58:36 +0300
committerJunio C Hamano <gitster@pobox.com>2022-08-06 00:13:12 +0300
commitb9342b3fd6308c351f53075c9c4339913b73451f (patch)
treeef50c609adb612e0ddb04f3ef0e72bfd8f3490c2 /refs.h
parent5797b13919f8073108e58ab5cea39f4e6bbfa1c9 (diff)
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>
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/refs.h b/refs.h
index 47cb9edbaa..d6575b8c2b 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_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 */