From 4ffbb02ee4bde38b4792b93cfba48755b394a130 Mon Sep 17 00:00:00 2001 From: Karthik Nayak Date: Wed, 25 Feb 2026 10:40:42 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- refs.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'refs.h') 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 */ -- cgit v1.3