aboutsummaryrefslogtreecommitdiff
path: root/refs.h
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2026-02-25 10:40:42 +0100
committerJunio C Hamano <gitster@pobox.com>2026-02-25 09:27:12 -0800
commit4ffbb02ee4bde38b4792b93cfba48755b394a130 (patch)
tree722ababfdbaacf3e806cf8c142a11827f94e8a67 /refs.h
parent2c69ff481938a10660c2078cf83235db26773254 (diff)
downloadgit-4ffbb02ee4bde38b4792b93cfba48755b394a130.tar.xz
refs: extract out `refs_create_refdir_stubs()`
For Git to recognize a directory as a Git directory, it requires the directory to contain: 1. 'HEAD' file 2. 'objects/' directory 3. 'refs/' directory Here, #1 and #3 are part of the reference storage mechanism, specifically the files backend. Since then, newer backends such as the reftable backend have moved to using their own path ('reftable/') for storing references. But to ensure Git still recognizes the directory as a Git directory, we create stubs. There are two locations where we create stubs: - In 'refs/reftable-backend.c' when creating the reftable backend. - In 'clone.c' before spawning transport helpers. In a following commit, we'll add another instance. So instead of repeating the code, let's extract out this code to `refs_create_refdir_stubs()` and use it. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/refs.h b/refs.h
index f0abfa1d93..a35fdc6642 100644
--- a/refs.h
+++ b/refs.h
@@ -1427,4 +1427,17 @@ void ref_iterator_free(struct ref_iterator *ref_iterator);
int do_for_each_ref_iterator(struct ref_iterator *iter,
each_ref_fn fn, void *cb_data);
+/*
+ * Git only recognizes a directory as a repository if it contains:
+ * - HEAD file
+ * - refs/ folder
+ * While it is necessary within the files backend, newer backends may not
+ * follow the same structure. To go around this, we create stubs as necessary.
+ *
+ * If provided with a 'refs_heads_content', we create the 'refs/heads/head' file
+ * with the provided message.
+ */
+void refs_create_refdir_stubs(struct repository *repo, const char *refdir,
+ const char *refs_heads_content);
+
#endif /* REFS_H */