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 --- builtin/clone.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index cd43bb5aa2..697c5bb5cb 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -1225,12 +1225,7 @@ int cmd_clone(int argc, initialize_repository_version(GIT_HASH_UNKNOWN, the_repository->ref_storage_format, 1); - strbuf_addf(&buf, "%s/HEAD", git_dir); - write_file(buf.buf, "ref: refs/heads/.invalid"); - - strbuf_reset(&buf); - strbuf_addf(&buf, "%s/refs", git_dir); - safe_create_dir(the_repository, buf.buf, 1); + refs_create_refdir_stubs(the_repository, git_dir, NULL); /* * additional config can be injected with -c, make sure it's included -- cgit v1.3