mirror of
https://github.com/git/git.git
synced 2026-03-05 14:59:04 +01:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
2c69ff4819
commit
4ffbb02ee4
@@ -491,18 +491,8 @@ static int reftable_be_create_on_disk(struct ref_store *ref_store,
|
||||
safe_create_dir(the_repository, sb.buf, 1);
|
||||
strbuf_reset(&sb);
|
||||
|
||||
strbuf_addf(&sb, "%s/HEAD", refs->base.gitdir);
|
||||
write_file(sb.buf, "ref: refs/heads/.invalid");
|
||||
adjust_shared_perm(the_repository, sb.buf);
|
||||
strbuf_reset(&sb);
|
||||
|
||||
strbuf_addf(&sb, "%s/refs", refs->base.gitdir);
|
||||
safe_create_dir(the_repository, sb.buf, 1);
|
||||
strbuf_reset(&sb);
|
||||
|
||||
strbuf_addf(&sb, "%s/refs/heads", refs->base.gitdir);
|
||||
write_file(sb.buf, "this repository uses the reftable format");
|
||||
adjust_shared_perm(the_repository, sb.buf);
|
||||
refs_create_refdir_stubs(the_repository, refs->base.gitdir,
|
||||
"this repository uses the reftable format");
|
||||
|
||||
strbuf_release(&sb);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user