From: Junio C Hamano Date: Thu, 29 Oct 2026 17:24:54 GMT Subject: Re: [PATCH] odb: do not list our own refs as alternate refs in the quarantine Message-ID: In-Reply-To: "Kristofer Karlsson via GitGitGadget" writes: > I also tried resolving the object directories that --alternate-refs uses > before the quarantine is created. That got a bit messy: it needed a new > internal rev-list option, and receive-pack had to carry the list of > directories through to each of its connectivity checks. And it only > fixes the check itself; other processes running inside the quarantine, > like pre-receive hooks, would still see the repository as its own > alternate. > > So the question is really where this should be fixed: is there a better > way for processes running inside the quarantine to tell the repository's > own object directory apart from real alternates? > @@ -190,6 +191,20 @@ static int refs_from_alternate_cb(struct odb_files_dir *alternate, > goto out; > if (!strbuf_strip_suffix(&path, "/objects")) > goto out; > + > + /* > + * NEEDSWORK: this is a hack, mainly here to measure the cost of > + * the bug. Inside an object quarantine, tmp-objdir passes our own > + * object directory to child processes as an alternate, so we would > + * list our own refs as alternate refs, including the hidden refs > + * that the connectivity check of receive-pack deliberately skips. > + * Comparing paths papers over that; the quarantine should rather > + * tell its children which directory is ours. > + */ In other words, if we tell our quarantine child where our real object directory is, say, via the 'GIT_QUARANTINE_OBJECT_DIRECTORY' environment variable, can the child notice the variable and identify which of the passed alternates is the real object directory, so that it knows not to use the refs associated with it? It is a bit of a shame that tmp_objdir_create() exports the same value as DB_ENVIRONMENT in GIT_QUARANTINE_ENVIRONMENT, as the only existing use of the latter is to check if the variable is exported or not---in other words, to carry a single bit of information ("are we in quarantine or not"). I wonder if we can change its value to name the parent process's real object directory instead? Then we would not need to export yet another variable to carry the information we need.