Git development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Igor Wiedler <iwiedler@gitlab.com>
Cc: git@vger.kernel.org, gitster@pobox.com, peff@peff.net,
	jltobler@gmail.com
Subject: Re: [PATCH v3 2/2] odb: ignore refs of shallow and grafted alternates
Date: Fri, 23 Oct 2026 12:43:47 +0200	[thread overview]
Message-ID: <ats6VLXUqKwKZzIY@pks.im> (raw)
In-Reply-To: <20261019110918.71193-3-iwiedler@gitlab.com>

On Mon, Oct 19, 2026 at 01:09:18PM +0200, Igor Wiedler wrote:
> odb_for_each_alternate_ref() reports the refs of every alternate
> object store that is a repository. Its three callers use them as
> commits whose history can be assumed to be present: "rev-list
> --alternate-refs" (and through it the connectivity check after a
> fetch), fetch-pack, which sends them as "have"s so that the server
> does not resend what the alternate has, and receive-pack, which
> advertises them as ".have".

Right, for all of these three callers it doesn't make any sense to
advertise those haves in case the repository is shallow. It's a somewhat
funny setup to have shallow alternates, but in case anybody does, this
change here would avoid a potentially corrupted repository.

> That assumption does not hold for a shallow repository, whose refs
> point at commits with no history behind them below its shallow
> boundary, nor for a grafted one. A repository borrowing objects from
> such an alternate does not see the alternate's shallow file, so the
> history that is missing there is missing here as well. The fetch then
> succeeds, the connectivity check stops at the alternate's refs, and
> a later "git log" fails with "Could not read <oid>".

Yup.

> "git clone --reference" already rejects a shallow or grafted
> reference repository for this reason, but nothing prevents such a
> repository from being added via objects/info/alternates or
> GIT_ALTERNATE_OBJECT_DIRECTORIES, or from being made shallow after
> other repositories started borrowing from it.
> 
> Skip the refs of an alternate that has a "shallow" file or an
> "info/grafts" file, the same checks clone uses. Its objects are still
> available through the object store. Only its refs are no longer used
> as a boundary.

It could of course be that somebody manually created such a repository
and due to some obscure reason still expects "--alternate-refs" to work.
But I feel like this use case is sufficiently unlikely to simply not
matter in practice, and the fact that Git refuses creating this setup in
the first place is a good indicator that nobody will care about this
change.

I feel like the whole concept of alternate refs is quite flawed in the
first place. We get as input an object directory and then we hope that
its parent directory _may_ be a proper repository.

Other than that this looks good to me, thanks!

Patrick

  reply	other threads:[~2026-10-23 10:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 10:35 [PATCH] connected: do not walk alternate refs in deepening fetches Igor Wiedler
2026-10-14 12:25 ` Patrick Steinhardt
2026-10-14 16:55 ` Junio C Hamano
2026-10-15  6:41   ` Jeff King
2026-10-14 17:02 ` Justin Tobler
2026-10-14 18:11 ` [PATCH v2 0/2] connected: fix the connectivity check with alternates " Igor Wiedler
2026-10-14 19:23   ` Junio C Hamano
2026-10-19 11:09   ` [PATCH v3 " Igor Wiedler
2026-10-19 23:12     ` Junio C Hamano
2026-10-20  7:55       ` Igor Wiedler
2026-10-23 10:44         ` Patrick Steinhardt
2026-10-19 11:09   ` [PATCH v3 1/2] connected: negate alternate refs in deepening fetches too Igor Wiedler
2026-10-19 11:09   ` [PATCH v3 2/2] odb: ignore refs of shallow and grafted alternates Igor Wiedler
2026-10-23 10:43     ` Patrick Steinhardt [this message]
2026-10-14 18:11 ` [PATCH v2 1/2] connected: negate alternate refs in deepening fetches too Igor Wiedler
2026-10-14 18:11 ` [PATCH v2 2/2] odb: ignore refs of shallow and grafted alternates Igor Wiedler
2026-10-15  6:57   ` Jeff King
2026-10-15 17:25     ` Junio C Hamano
2026-10-16  3:14   ` Jeff King
2026-10-19 11:02     ` Igor Wiedler
2026-10-18  1:19   ` 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=ats6VLXUqKwKZzIY@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=iwiedler@gitlab.com \
    --cc=jltobler@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox