Subject: Re: [PATCH v2 3/3] upload-pack: allow configuring a missing-action

From: Junio C Hamano <[email-masked]>
Date: Wed, 15 May 2024 10:08:58 -0700

Christian Couder <[email-masked]> writes:

> From: Christian Couder <[email-masked]>
>
> In case some objects are missing from a server, it might still be
> useful to be able to fetch or clone from it if the client already has
> the missing objects or can get them in some way.

Be more assertive.  We do not want to add a new feature randomly
only because it _might_ be useful to somebody in a strange and
narrow use case that _might_ exist.

> For example, in case both the server and the client are using a
> separate promisor remote that contain some objects, it can be better
> if the server doesn't try to send such objects back to the client, but
> instead let the client get those objects separately from the promisor
> remote. (The client needs to have the separate promisor remote
> configured, for that to work.)

Is it "it can be better", or is it "it is always better"?  Pick an
example that you can say the latter to make your example more
convincing.

Repository S borrows from its "promisor" X, and repository C which
initially cloned from S borrows from its "promisor" S.  Even if C
wants an object in order to fill in the gap in its object graph, S
may not have it (and S itself may have no need for that object), and
in such a case, bypassing S and let C go directly to X would make
sense.

> Another example could be a server where some objects have been
> corrupted or deleted. It could still be useful for clients who could
> get those objects from another source, like perhaps a different
> client, to be able to fetch or clone from the server.
>
> To configure what a server should do if there are such missing
> objects, let's teach `git upload-pack` a new
> `uploadpack.missingAction` configuration variable.
>
> This new missing-action works in a similar way as what `git rev-list`
> and `git pack-objects` already support with their
> `--missing=<missing-action>` command line options. In fact when
> `uploadpack.missingAction` is set to something different than "error",
> `git upload-pack` will just pass the corresponding
> `--missing=<missing-action>` to `git pack-objects`.
>
> So this new missing-action has the same limitations as
> `git pack-objects --missing=<missing-action>`. Especially when not
> using promisor remotes, 'allow-any' works only for blobs.
>
> Another limitation comes from `git upload-pack` itself which requires
> setting `GIT_NO_LAZY_FETCH` to 0 since 7b70e9efb1 (upload-pack:
> disable lazy-fetching by default, 2024-04-16) for lazy fetching from
> a promisor remote to work on the server side.

I am puzzled by this new option.

It feels utterly irresponsible to give an option to set up a server
that essentially declares: I'll serve objects you ask me as best
efforts basis, the pack stream I'll give you may not have all
objects you asked for and missing some objects, and when I do so, I
am not telling you which objects I omitted.

How do you ensure that a response with an incomplete pack data would
not corrupt the repository when the sending side configures
upload-pack with this option?  How does the receiving end know which
objects it needs to ask from elsewhere?

Or is the data integrity of the receiving repository is the
responsibility of the receiving user that talks with such a server?
If that is the case, I am not sure if I want to touch such a feature
even with 10ft pole.

Is there anything the sender can do but does not do to help the
receiver locate where to fetch these missing objects to fill the
"unfilled promises"?

For example, the sending side _could_ say that "Sorry, I do not have
all objects that you asked me to---but you could try these other
repositories".