transport-helper: drop "object-format <algo>" option

The documentation in gitremote-helpers.txt claims that helpers should accept an object-format option from Git whose value is either: 1. "true", in which case the helper is merely told that Git understands the special ":object-format" response, and will send it 2. an algorithm name that the helper should use However, Git has never sent the second form, and it's not clear if it would ever be useful. When interacting with a remote Git repository, we generally discover what _their_ object format is, and then decide what to do with a mismatch (where that is currently just "bail out", but could eventually be on-the-fly conversion and interop). And that is true for native protocols, but also for transport helpers like remote-curl that talk to remote Git repositories. There we send back an ":object-format" line telling Git what remote-curl detected on the other side. And this is true even for pushes (since we get it via receive-pack's advertisement). And it is even true for dumb-http, as we guess at the algorithm based on the hash size, due to ac093d0790 (remote-curl: detect algorithm for dumb HTTP by size, 2020-06-19). The one case where it _isn't_ true is dumb-http talking to an empty repository. There we have no clue what the remote hash is, so remote-curl just sends back its default. If we kept the "object-format <algo>" form then in theory Git could say "object-format sha256" to change that default. But it doesn't really accomplish anything. We still may or may not be mis-matched with the other side. For a fetch that's OK, since it's by definition a noop. For a push into an empty repository, it might matter (though the dumb http-push DAV code seems happy to clobber a remote sha256 info/refs and corrupt the repository). If we want to pursue making this work, I think we'd be better off improving detection of the object format of empty repositories over dumb-http (e.g., an "info/object-format" file). But what about helpers that _aren't_ talking to another Git repo? Consider something like git-cinnabar, which is converting on the fly to/from hg. Most of the heavy lifting is done by fast-import/export, but some oids may still pass between Git and the helper. Could "object-format <algo>" be useful to tell the helper what oids we expect to see? Possibly, but in practice this isn't necessary. Git-cinnabar for example already peeks at the local-repo .git/config to check its object-format (and currently just bails if it is sha256). So I think the "object-format" extension really is only useful for the helper telling Git what object-format it found, and not the other way around. Note that this patch can't break any remote helpers; we're not changing the code on the Git side at all, but just bringing the documentation in line with what Git has always done. It does remove the receiving support in remote-curl.c, but that code was never actually triggered. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 20, 2024 at 05:37 UTC d6f6b433a87a0157b2f1bc45a3758841fc14fb8b
2 files changed +4 -12
Documentation/gitremote-helpers.txt
+2 -5
@@ -542,13 +542,10 @@ set by Git if the remote helper has the 'option' capability.
542 transaction. If successful, all refs will be updated, or none will. If the
543 remote side does not support this capability, the push will fail.
544
545 -'option object-format' {'true'|algorithm}::
546 - If 'true', indicate that the caller wants hash algorithm information
545 +'option object-format true'::
546 + Indicate that the caller wants hash algorithm information
547 to be passed back from the remote. This mode is used when fetching
548 refs.
549 -+
550 -If set to an algorithm, indicate that the caller wants to interact with
551 -the remote side using that algorithm.
549
550 SEE ALSO
551 --------
remote-curl.c
+2 -7
@@ -211,14 +211,9 @@ static int set_option(const char *name, const char *value)
211 options.filter = xstrdup(value);
212 return 0;
213 } else if (!strcmp(name, "object-format")) {
214 - int algo;
214 options.object_format = 1;
216 - if (strcmp(value, "true")) {
217 - algo = hash_algo_by_name(value);
218 - if (algo == GIT_HASH_UNKNOWN)
219 - die("unknown object format '%s'", value);
220 - options.hash_algo = &hash_algos[algo];
221 - }
215 + if (strcmp(value, "true"))
216 + die(_("unknown value for object-format: %s"), value);
217 return 0;
218 } else {
219 return 1 /* unsupported */;