{"thread":{"id":"66929","subject":"[PATCH] remote-curl: honor --no-thin when pushing","startedAt":"2026-11-25T08:38:06Z","lastAt":"2026-11-25T08:38:06Z","messageCount":1,"participants":["Julian Maurin via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"559329","messageId":"pull.2328.git.1795595886592.gitgitgadget@gmail.com","threadId":"66929","inReplyTo":null,"subject":"[PATCH] remote-curl: honor --no-thin when pushing","fromName":"Julian Maurin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-25T08:38:06Z","receivedAt":"2026-11-25T08:38:06Z","isPatch":true,"sender":{"key":"name:Julian Maurin","avatar":null},"body":"From: Julian Maurin <julian.maurin.dev@proton.me>\n\n\"git push --no-thin\" to a smart HTTP remote still sends a thin pack.\ntransport-helper.c does not forward the \"thin\" option to remote\nhelpers, and remote-curl always runs send-pack with --thin.\n\n\"thin\" was left out of the forwarded options of ef08ef9ea0\n(remote-helpers: Support custom transport options, 2009-10-30) after\nreview noted that --no-thin did nothing on any transport at the time.\nf7c815c3ee (push: respect --no-thin, 2013-08-12) made it work again,\nbut only for the native transports.\n\nForward \"thin\" to helpers and teach remote-curl to honor it. A helper\nthat does not know the option answers \"unsupported\", which push\nignores, so it keeps working as before.\n\nSigned-off-by: Julian Maurin <julian.maurin.dev@proton.me>\n---\n    remote-curl: honor --no-thin when pushing\n    \n    \"git push --no-thin\" over smart HTTP was ignored and a thin pack was\n    sent anyway, which has been corrected.\n    \n    I ran into this in production, pushing from a shallow, treeless partial\n    clone (--filter=tree:0) to an HTTPS remote. In a shallow repository a\n    thin push reads the tree of every advertised tip it has locally, and\n    each missing tree is lazily fetched from the promisor remote, one fetch\n    per tree. --no-thin avoids that work, but has no effect over HTTP.\n    \n    A small reproduction with the test suite's httpd (400 commits, 40\n    advertised refs, a --depth=180 --filter=tree:0 clone pushing a merge):\n    \n    default push:                   37 lazy fetches\n    --no-thin, without this patch:  37 lazy fetches\n    --no-thin, with this patch:      0 lazy fetches\n    \n    \n    Helpers with the \"connect\" capability (ext::, fd::) already honor\n    --no-thin, as the native transport code takes over their connection.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2328%2FJulianMaurin%2Fpush-no-thin-over-http-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2328/JulianMaurin/push-no-thin-over-http-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2328\n\n Documentation/gitremote-helpers.adoc |  4 ++++\n remote-curl.c                        |  8 ++++++++\n t/t5541-http-push-smart.sh           | 17 +++++++++++++++++\n transport-helper.c                   |  1 -\n 4 files changed, 29 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/gitremote-helpers.adoc b/Documentation/gitremote-helpers.adoc\nindex 39cdece16e..8203ef497c 100644\n--- a/Documentation/gitremote-helpers.adoc\n+++ b/Documentation/gitremote-helpers.adoc\n@@ -542,6 +542,10 @@ set by Git if the remote helper has the 'option' capability.\n \ttransaction.  If successful, all refs will be updated, or none will.  If the\n \tremote side does not support this capability, the push will fail.\n \n+'option thin' {'true'|'false'}::\n+\tWhen pushing, request the helper to send a thin pack (see\n+\t`--thin` in linkgit:git-pack-objects[1]).\n+\n 'option object-format true'::\n \tIndicate that the caller wants hash algorithm information\n \tto be passed back from the remote.  This mode is used when fetching\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 2c35dd5240..8309d9d2a4 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -184,6 +184,14 @@ static int set_option(const char *name, size_t namelen, const char *value)\n \t\telse\n \t\t\treturn -1;\n \t\treturn 0;\n+\t} else if (!strncmp(name, TRANS_OPT_THIN, namelen)) {\n+\t\tif (!strcmp(value, \"true\"))\n+\t\t\toptions.thin = 1;\n+\t\telse if (!strcmp(value, \"false\"))\n+\t\t\toptions.thin = 0;\n+\t\telse\n+\t\t\treturn -1;\n+\t\treturn 0;\n \t} else if (!strncmp(name, \"push-option\", namelen)) {\n \t\tif (*value != '\"')\n \t\t\tstring_list_append(&options.push_options, value);\ndiff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh\nindex 8c34833027..280b2d9078 100755\n--- a/t/t5541-http-push-smart.sh\n+++ b/t/t5541-http-push-smart.sh\n@@ -253,6 +253,23 @@ test_expect_success 'push --atomic fails on server-side errors' '\n \ttest_grep \"^ ! .*rejected.* atomic -> atomic .*atomic transaction failed\" output\n '\n \n+test_expect_success 'push --[no-]thin is passed to pack-objects' '\n+\td=$HTTPD_DOCUMENT_ROOT_PATH/no-thin.git &&\n+\tgit init --bare \"$d\" &&\n+\ttest_config -C \"$d\" http.receivepack true &&\n+\tup=\"$HTTPD_URL\"/smart/no-thin.git &&\n+\tgit push \"$up\" main &&\n+\n+\ttest_commit thin-default &&\n+\tGIT_TRACE2_EVENT=\"$PWD/trace-thin\" git push \"$up\" main &&\n+\ttest_subcommand_flex git pack-objects --thin <trace-thin &&\n+\n+\ttest_commit thin-disabled &&\n+\tGIT_TRACE2_EVENT=\"$PWD/trace-no-thin\" git push --no-thin \"$up\" main &&\n+\ttest_subcommand_flex git pack-objects <trace-no-thin &&\n+\ttest_subcommand_flex ! git pack-objects --thin <trace-no-thin\n+'\n+\n test_expect_success 'push --all can push to empty repo' '\n \td=$HTTPD_DOCUMENT_ROOT_PATH/empty-all.git &&\n \tgit init --bare \"$d\" &&\ndiff --git a/transport-helper.c b/transport-helper.c\nindex d5a064d386..6052407b9a 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -275,7 +275,6 @@ static int disconnect_helper(struct transport *transport)\n static const char *unsupported_options[] = {\n \tTRANS_OPT_UPLOADPACK,\n \tTRANS_OPT_RECEIVEPACK,\n-\tTRANS_OPT_THIN,\n \tTRANS_OPT_KEEP\n \t};\n \n\nbase-commit: 03b41523c576f26ad34085378717a0c1b287470f\n-- \ngitgitgadget\n\n"}]}