From: Patrick Steinhardt <ps@pks.im>
To: Kristofer Karlsson via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Justin Tobler <jltobler@gmail.com>,
Kristofer Karlsson <krka@spotify.com>
Subject: Re: [PATCH v2] odb: do not list our own refs as alternate refs in the quarantine
Date: Tue, 3 Nov 2026 12:00:47 +0100 [thread overview]
Message-ID: <aum-34I8KZvTfDRT@pks.im> (raw)
In-Reply-To: <pull.2285.v2.git.1793619933300.gitgitgadget@gmail.com>
On Mon, Nov 02, 2026 at 11:45:33AM +0000, Kristofer Karlsson via GitGitGadget wrote:
> diff --git a/odb/source-files.c b/odb/source-files.c
> index 5b4277fbfd..223af45dd9 100644
> --- a/odb/source-files.c
> +++ b/odb/source-files.c
> @@ -348,6 +351,45 @@ static int read_alternates(const char *object_dir, struct strvec *out)
> return 0;
> }
>
> +/*
> + * Our own object directory is <commondir>/objects, or the parent of
> + * GIT_QUARANTINE_PATH, as an object quarantine is created directly
Or it may be derived from `files://<payload>` with the object storage
format extension.
> + * inside it (see tmp_objdir_create()). Anything else, including a path
> + * that cannot be resolved, is borrowed.
> + */
> +static bool is_borrowed_object_dir(struct odb_source_files *files,
> + const char *path)
> +{
> + struct strbuf real = STRBUF_INIT;
> + struct strbuf objdir = STRBUF_INIT;
> + struct strbuf self = STRBUF_INIT;
> + bool ret = true;
> +
> + if (!strbuf_realpath(&real, path, 0))
> + goto out;
> +
> + strbuf_addf(&objdir, "%s/objects", files->base.odb->repo->commondir);
> + if (strbuf_realpath(&self, objdir.buf, 0) &&
> + !fspathcmp(real.buf, self.buf)) {
> + ret = false;
> + goto out;
> + }
So this here isn't fully correct as it does not account for all cases.
We'd have to read the object storage format extension to figure out
where the primary object directory lives.
> @@ -1256,15 +1299,19 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,
> struct odb_source_files *files;
> char *object_dir = NULL;
> char *alternates = NULL;
> + char *quarantine_path = NULL;
>
> if (flags & ODB_NEW_HONOR_ENV) {
> object_dir = xstrdup_or_null(getenv(DB_ENVIRONMENT));
> alternates = xstrdup_or_null(getenv(ALTERNATE_DB_ENVIRONMENT));
> + quarantine_path =
> + xstrdup_or_null(getenv(GIT_QUARANTINE_ENVIRONMENT));
> }
> if (!object_dir)
> object_dir = xstrfmt("%s/objects", odb->repo->commondir);
>
> CALLOC_ARRAY(files, 1);
> + files->quarantine_path = quarantine_path;
> odb_source_init(&files->base, odb, ODB_SOURCE_FILES, object_dir);
>
> hashmap_init(&files->dirs_by_path, odb_files_dir_by_path_cmp, files, 0);
This makes me wonder whether the better fix would be to stop modifying
the primary object directory and instead we simply append the quarantine
directory to alternates. The presence of `GIT_QUARANTINE_ENVIRONMENT`
could then serve as an indicator that the child process is not allowed
to write objects.
That's a much bigger change in semantics though, and the risk of causing
a regression would be quite a bit higher. But the upside is that we
wouldn't have to juggle alternates anymore, and your case with alternate
refs would "just work".
Patrick
next prev parent reply other threads:[~2026-11-03 11:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 15:18 [PATCH] odb: do not list our own refs as alternate refs in the quarantine Kristofer Karlsson via GitGitGadget
2026-10-29 16:57 ` Justin Tobler
2026-10-30 11:29 ` Kristofer Karlsson
2026-10-29 17:24 ` Junio C Hamano
2026-10-30 11:51 ` Kristofer Karlsson
2026-10-30 16:05 ` Junio C Hamano
2026-10-30 18:17 ` Jeff King
2026-11-02 11:45 ` [PATCH v2] " Kristofer Karlsson via GitGitGadget
2026-11-03 0:37 ` Junio C Hamano
2026-11-03 1:12 ` Junio C Hamano
2026-11-03 10:19 ` Kristofer Karlsson
2026-11-03 11:00 ` Patrick Steinhardt [this message]
2026-11-03 12:05 ` Kristofer Karlsson
2026-11-03 12:26 ` Patrick Steinhardt
2026-11-03 21:53 ` Justin Tobler
2026-11-04 10:32 ` Kristofer Karlsson
2026-11-04 16:58 ` Justin Tobler
2026-11-04 2:48 ` Jeff King
2026-11-04 10:25 ` Kristofer Karlsson
2026-11-04 18:05 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aum-34I8KZvTfDRT@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=jltobler@gmail.com \
--cc=krka@spotify.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.