From: Julian Maurin via GitGitGadget Date: Thu, 26 Nov 2026 09:19:06 GMT Subject: [PATCH v2] remote-curl: honor --no-thin when pushing Message-ID: In-Reply-To: From: Julian Maurin "git push --no-thin" to a smart HTTP remote still sends a thin pack. transport-helper.c does not forward the "thin" option to remote helpers, and remote-curl always runs send-pack with --thin. If one pushes from a shallow, treeless partial clone (--filter=tree:0) to an HTTPS remote, a thin push lazily fetches every advertised tip's missing tree from the promisor one by one, and --no-thin has no effect over HTTP to avoid it. "thin" was left out of the forwarded options of ef08ef9ea0 (remote-helpers: Support custom transport options, 2009-10-30) after review noted that --no-thin did nothing on any transport at the time. f7c815c3ee (push: respect --no-thin, 2013-08-12) made it work again, but only for the native transports. Forward "thin" to helpers and teach remote-curl to honor it. A helper that does not know the option answers "unsupported", which push ignores, so it keeps working as before. Helped-by: Junio C Hamano Signed-off-by: Julian Maurin --- remote-curl: honor --no-thin when pushing Changes since v1: * Added the use case (a push from a shallow, treeless partial clone) to the commit message, in Junio's wording. Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2328%2FJulianMaurin%2Fpush-no-thin-over-http-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2328/JulianMaurin/push-no-thin-over-http-v2 Pull-Request: https://github.com/gitgitgadget/git/pull/2328 Range-diff vs v1: 1: c3fb36cb75 ! 1: 8732cf64fc remote-curl: honor --no-thin when pushing @@ Commit message transport-helper.c does not forward the "thin" option to remote helpers, and remote-curl always runs send-pack with --thin. + If one pushes from a shallow, treeless partial clone + (--filter=tree:0) to an HTTPS remote, a thin push lazily fetches + every advertised tip's missing tree from the promisor one by one, + and --no-thin has no effect over HTTP to avoid it. + "thin" was left out of the forwarded options of ef08ef9ea0 (remote-helpers: Support custom transport options, 2009-10-30) after review noted that --no-thin did nothing on any transport at the time. @@ Commit message that does not know the option answers "unsupported", which push ignores, so it keeps working as before. + Helped-by: Junio C Hamano Signed-off-by: Julian Maurin ## Documentation/gitremote-helpers.adoc ## Documentation/gitremote-helpers.adoc | 4 ++++ remote-curl.c | 8 ++++++++ t/t5541-http-push-smart.sh | 17 +++++++++++++++++ transport-helper.c | 1 - 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Documentation/gitremote-helpers.adoc b/Documentation/gitremote-helpers.adoc index 39cdece16e..8203ef497c 100644 --- a/Documentation/gitremote-helpers.adoc +++ b/Documentation/gitremote-helpers.adoc @@ -542,6 +542,10 @@ set by Git if the remote helper has the 'option' capability. transaction. If successful, all refs will be updated, or none will. If the remote side does not support this capability, the push will fail. +'option thin' {'true'|'false'}:: + When pushing, request the helper to send a thin pack (see + `--thin` in linkgit:git-pack-objects[1]). + 'option object-format true':: Indicate that the caller wants hash algorithm information to be passed back from the remote. This mode is used when fetching diff --git a/remote-curl.c b/remote-curl.c index 2c35dd5240..8309d9d2a4 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -184,6 +184,14 @@ static int set_option(const char *name, size_t namelen, const char *value) else return -1; return 0; + } else if (!strncmp(name, TRANS_OPT_THIN, namelen)) { + if (!strcmp(value, "true")) + options.thin = 1; + else if (!strcmp(value, "false")) + options.thin = 0; + else + return -1; + return 0; } else if (!strncmp(name, "push-option", namelen)) { if (*value != '"') string_list_append(&options.push_options, value); diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index 8c34833027..280b2d9078 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -253,6 +253,23 @@ test_expect_success 'push --atomic fails on server-side errors' ' test_grep "^ ! .*rejected.* atomic -> atomic .*atomic transaction failed" output ' +test_expect_success 'push --[no-]thin is passed to pack-objects' ' + d=$HTTPD_DOCUMENT_ROOT_PATH/no-thin.git && + git init --bare "$d" && + test_config -C "$d" http.receivepack true && + up="$HTTPD_URL"/smart/no-thin.git && + git push "$up" main && + + test_commit thin-default && + GIT_TRACE2_EVENT="$PWD/trace-thin" git push "$up" main && + test_subcommand_flex git pack-objects --thin