git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v7 3/6] refs: move out stub modification to generic layer

From
Toon Claes <toon@iotcl.com>
Date
Feb 20, 2026, 15:21 UTC
Message-ID
<877bs7fnkr.fsf@iotcl.com>
In-Reply-To
<20260219-kn-alternate-ref-dir-v7-3-16f27860dbdf@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 39 quoted lines
> When creating the reftable reference backend on disk, we create stubs to
> ensure that the directory can be recognized as a Git repository. This is
> done by calling `refs_create_refdir_stubs()`. Move this to the generic
> layer as this is needed for all backends excluding from the files
> backends. In an upcoming commit where we introduce alternate reference
> backend locations, we'll have to also create stubs in the $GIT_DIR
> irrespective of the backend being used. This commit builds the base to
> add that logic.
>
> Similarly, move the logic for deletion of stubs to the generic layer.
> The files backend recursively calls the remove function of the
> 'packed-backend', here skip calling the generic function since that
> would try to delete stubs.
>
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
>  refs.c                  | 47 +++++++++++++++++++++++++++++++++++++++++++++--
>  refs/files-backend.c    |  6 +++++-
>  refs/reftable-backend.c | 27 ---------------------------
>  3 files changed, 50 insertions(+), 30 deletions(-)
>
> diff --git a/refs.c b/refs.c
> index 77b93d655b..c83af63dc5 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -2189,12 +2189,55 @@ void refs_create_refdir_stubs(struct repository *repo, const char *refdir,
>  /* backend functions */
>  int ref_store_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err)
>  {
> -	return refs->be->create_on_disk(refs, flags, err);
> +	int ret = refs->be->create_on_disk(refs, flags, err);
> +
> +	if (!ret &&
> +	    ref_storage_format_by_name(refs->be->name) != REF_STORAGE_FORMAT_FILES) {
> +		struct strbuf msg = STRBUF_INIT;
> +
> +		strbuf_addf(&msg, "this repository uses the %s format", refs->be->name);
> +		refs_create_refdir_stubs(refs->repo, refs->gitdir, msg.buf);
> +		strbuf_release(&msg);

To me it would feel nicer to have an early return instead of wrapping this code inside the if block. But because we only need the strbuf instead this block, having a block to scope it makes more sense.

Looks good to me.
-- 
Cheers,
Toon
Previous: Karthik NayakNext: Karthik Nayak
Message 5 of 15 in “refs: allow setting the reference directory”
  1. 0/6 refs: allow setting the reference directoryKarthik Nayak, Feb 19, 2026
  2. 1/6 setup: don't modify repo in `create_reference_database()`Karthik Nayak, Feb 19, 2026
  3. 2/6 refs: extract out `refs_create_refdir_stubs()`Karthik Nayak, Feb 19, 2026
  4. 3/6 refs: move out stub modification to generic layerKarthik Nayak, Feb 19, 2026
  5. Toon ClaesFeb 20, 2026
  6. 4/6 refs: receive and use the reference storage payloadKarthik Nayak, Feb 19, 2026
  7. Toon ClaesFeb 20, 2026
  8. Karthik NayakFeb 22, 2026
  9. 5/6 refs: allow reference location in refstorage configKarthik Nayak, Feb 19, 2026
  10. Toon ClaesFeb 20, 2026
  11. Junio C HamanoFeb 20, 2026
  12. Karthik NayakFeb 22, 2026
  13. 6/6 refs: add GIT_REFERENCE_BACKEND to specify reference backendKarthik Nayak, Feb 19, 2026
  14. Patrick SteinhardtFeb 19, 2026
  15. Karthik NayakFeb 20, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.