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

Re: [PATCH] odb: do not list our own refs as alternate refs in the quarantine

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 29, 2026, 17:24 UTC
Message-ID
<xmqqfqxo4dy1.fsf@gitster.g>
In-Reply-To
<pull.2285.git.1793200705017.gitgitgadget@gmail.com>

"Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com> writes:

Show 11 quoted lines
>     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?
Show 14 quoted lines
> @@ -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.

Previous: Kristofer KarlssonNext: Kristofer Karlsson
Message 4 of 7 in “odb: do not list our own refs as alternate refs in the quarantine”
  1. odb: do not list our own refs as alternate refs in the quarantineKristofer Karlsson via GitGitGadget, Oct 28, 2026
  2. Justin ToblerOct 29, 2026
  3. Kristofer KarlssonOct 30, 2026
  4. Junio C HamanoOct 29, 2026
  5. Kristofer KarlssonOct 30, 2026
  6. Junio C HamanoOct 30, 2026
  7. Jeff KingOct 30, 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.