Skip to content

remote-curl: honor --no-thin when pushing - #2328

Open
JulianMaurin wants to merge 1 commit into
gitgitgadget:maintfrom
JulianMaurin:push-no-thin-over-http
Open

JulianMaurin wants to merge 1 commit into
gitgitgadget:maintfrom
JulianMaurin:push-no-thin-over-http

Conversation

@JulianMaurin

@JulianMaurin JulianMaurin commented Nov 24, 2026 •

Copy link
Copy Markdown

Changes since v1:

  • Added the use case (a push from a shallow, treeless partial clone)
    to the commit message, in Junio's wording.

cc: Jeff King peff@peff.net
cc: "brian m. carlson" sandals@crustytoothpaste.net
cc: Patrick Steinhardt ps@pks.im
cc: Julian Maurin julian.maurin.dev@proton.me

@gitgitgadget

gitgitgadget Bot commented Nov 24, 2026

Copy link
Copy Markdown

Welcome to GitGitGadget

Hi @JulianMaurin, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that either:

  • Your Pull Request has a good description, if it consists of multiple commits, as it will be used as cover letter.
  • Your Pull Request description is empty, if it consists of a single commit, as the commit message should be descriptive enough by itself.

You can CC potential reviewers by adding a footer to the PR description with the following syntax:

CC: Revi Ewer <revi.ewer@example.com>, Ill Takalook <ill.takalook@example.net>

NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description,
because it will result in a malformed CC list on the mailing list. See
example.

Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "revisions:" to state which subsystem the change is about, and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.

Contributing the patches

Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form /allow. A good way to find other contributors is to locate recent pull requests where someone has been /allowed:

Both the person who commented /allow and the PR author are able to /allow you.

An alternative is the channel #git-devel on the Libera Chat IRC network:

<newcontributor> I've just created my first PR, could someone please /allow me? https://github.com/gitgitgadget/git/pull/12345
<veteran> newcontributor: it is done
<newcontributor> thanks!

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

If you want to see what email(s) would be sent for a /submit request, add a PR comment /preview to have the email(s) sent to you. You must have a public GitHub email address for this. Note that any reviewers CC'd via the list in the PR description will not actually be sent emails.

After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail).

If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the (raw) link), then import it into your mail program. If you use GMail, you can do this via:

curl -g --user "<EMailAddress>:<Password>" \
    --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):

Changes since v1:
- Fixed a typo in the commit message (found by ...)
- Added a code comment to ... as suggested by ...
...

To send a new iteration, just add another PR comment with the contents: /submit.

Need help?

New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join.

You may also be able to find help in real time in the developer IRC channel, #git-devel on Libera Chat. Remember that IRC does not support offline messaging, so if you send someone a private message and log out, they cannot respond to you. The scrollback of #git-devel is archived, though.

@JulianMaurin

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 24, 2026

Copy link
Copy Markdown

Error: User JulianMaurin is not yet permitted to use GitGitGadget

@dscho

dscho commented Nov 24, 2026

Copy link
Copy Markdown
Member

/allow

@gitgitgadget

gitgitgadget Bot commented Nov 24, 2026

Copy link
Copy Markdown

User JulianMaurin is now allowed to use GitGitGadget.

@JulianMaurin

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 24, 2026

Copy link
Copy Markdown

Preview email sent as pull.2328.git.1795536161794.gitgitgadget@gmail.com

@JulianMaurin

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 24, 2026

Copy link
Copy Markdown

Preview email sent as pull.2328.git.1795536445529.gitgitgadget@gmail.com

@JulianMaurin

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Submitted as pull.2328.git.1795595886592.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2328/JulianMaurin/push-no-thin-over-http-v1

To fetch this version to local tag pr-2328/JulianMaurin/push-no-thin-over-http-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2328/JulianMaurin/push-no-thin-over-http-v1

"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 ef08ef9
(remote-helpers: Support custom transport options, 2009-10-30) after
review noted that --no-thin did nothing on any transport at the time.
f7c815c (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 <gitster@pobox.com>
Signed-off-by: Julian Maurin <julian.maurin.dev@proton.me>
@JulianMaurin
JulianMaurin force-pushed the push-no-thin-over-http branch from c3fb36c to 8732cf6 Compare November 25, 2026 20:09
@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

This patch series was integrated into seen via git@d284a70.

@gitgitgadget gitgitgadget Bot added the seen label Nov 25, 2026
@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Julian Maurin via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Julian Maurin <julian.maurin.dev@proton.me>
>
> "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.
>
> "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.
>
> Signed-off-by: Julian Maurin <julian.maurin.dev@proton.me>
> ---

Sounds like a clean fix.

>    I ran into this in production, pushing from a shallow, treeless partial
>    clone (--filter=tree:0) to an HTTPS remote. In a shallow repository a
>    thin push reads the tree of every advertised tip it has locally, and
>    each missing tree is lazily fetched from the promisor remote, one fetch
>    per tree. --no-thin avoids that work, but has no effect over HTTP.

Some of the supporting materials under the three-dash line, like the use
case that benefits from avoiding lazy tree fetches from a shallow,
treeless partial clone, make the motivation very clear, and may want to
be included in the commit log message, perhaps in a bit more condensed
form?  Here is my attempt.

    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.

> 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;

The above two hunks match with each other, naturally.

In remote-curl.c:cmd_main(), '.thin' of 'options' defaults to 1 (side
note: I didn't know that ;-)), and push_git() passes "--thin" to send-pack
only when '.thin' is set.  Honoring 'true' and 'false' here while
returning -1 for invalid values matches the surrounding boolean options
in set_option().

It is an unrelated tangent, but the use of strncmp() with namelen means
set_option("t", 1, "true") would allow setting 'thin' to 'true'.  Git
internally always sends the full option name, so it does not cause any
problem in practice, and it certainly is the right thing for this patch
to do to imitate the surrounding code.  But we may want to take another
look at these uses of strncmp() when the dust settles (#leftoverbits).

> diff --git a/transport-helper.c b/transport-helper.c
> index d5a064d386..6052407b9a 100644
> --- a/transport-helper.c
> +++ b/transport-helper.c
> @@ -275,7 +275,6 @@ static int disconnect_helper(struct transport *transport)
>  static const char *unsupported_options[] = {
>  	TRANS_OPT_UPLOADPACK,
>  	TRANS_OPT_RECEIVEPACK,
> -	TRANS_OPT_THIN,
>  	TRANS_OPT_KEEP
>  	};

Running 'git grep TRANS_OPT_THIN' tells me that builtin/push.c is the
only thing that sets TRANS_OPT_THIN via transport_set_option().  We used
to claim that this was unsupported, but when push asks to use it, we now
pass it through.

set_helper_option() notices that the boolean_options[] array still has
this token, and sets 'option thin true' or 'option thin false' depending
on the value and calls strbuf_set_helper_option() to send it out.

It is a bit surprising that there is absolutely nothing else that needs
to be added to support the option, but given that this was about
resurrecting a feature that already exists but was left castrated due to
a historical mistake, it is an understandable confusion on the reader's
side ;-)

Looking good.

Thanks.

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Julian Maurin wrote on the Git mailing list (how to reply to this email):

> Here is my attempt.
>
>     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.

Thanks, that reads better than what I had. I'll take it as is in v2.

> But we may want to take another look at these uses of strncmp() when
> the dust settles (#leftoverbits).

Agreed, that is for a separate patch.

Thanks for the review.

Julian


On Wednesday, November 25th, 2026 at 18:57, Junio C Hamano <gitster@pobox.com> wrote:

> "Julian Maurin via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> > From: Julian Maurin <julian.maurin.dev@proton.me>
> >
> > "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.
> >
> > "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.
> >
> > Signed-off-by: Julian Maurin <julian.maurin.dev@proton.me>
> > ---
> 
> Sounds like a clean fix.
> 
> >    I ran into this in production, pushing from a shallow, treeless partial
> >    clone (--filter=tree:0) to an HTTPS remote. In a shallow repository a
> >    thin push reads the tree of every advertised tip it has locally, and
> >    each missing tree is lazily fetched from the promisor remote, one fetch
> >    per tree. --no-thin avoids that work, but has no effect over HTTP.
> 
> Some of the supporting materials under the three-dash line, like the use
> case that benefits from avoiding lazy tree fetches from a shallow,
> treeless partial clone, make the motivation very clear, and may want to
> be included in the commit log message, perhaps in a bit more condensed
> form?  Here is my attempt.
> 
>     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.
> 
> > 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;
> 
> The above two hunks match with each other, naturally.
> 
> In remote-curl.c:cmd_main(), '.thin' of 'options' defaults to 1 (side
> note: I didn't know that ;-)), and push_git() passes "--thin" to send-pack
> only when '.thin' is set.  Honoring 'true' and 'false' here while
> returning -1 for invalid values matches the surrounding boolean options
> in set_option().
> 
> It is an unrelated tangent, but the use of strncmp() with namelen means
> set_option("t", 1, "true") would allow setting 'thin' to 'true'.  Git
> internally always sends the full option name, so it does not cause any
> problem in practice, and it certainly is the right thing for this patch
> to do to imitate the surrounding code.  But we may want to take another
> look at these uses of strncmp() when the dust settles (#leftoverbits).
> 
> > diff --git a/transport-helper.c b/transport-helper.c
> > index d5a064d386..6052407b9a 100644
> > --- a/transport-helper.c
> > +++ b/transport-helper.c
> > @@ -275,7 +275,6 @@ static int disconnect_helper(struct transport *transport)
> >  static const char *unsupported_options[] = {
> >  	TRANS_OPT_UPLOADPACK,
> >  	TRANS_OPT_RECEIVEPACK,
> > -	TRANS_OPT_THIN,
> >  	TRANS_OPT_KEEP
> >  	};
> 
> Running 'git grep TRANS_OPT_THIN' tells me that builtin/push.c is the
> only thing that sets TRANS_OPT_THIN via transport_set_option().  We used
> to claim that this was unsupported, but when push asks to use it, we now
> pass it through.
> 
> set_helper_option() notices that the boolean_options[] array still has
> this token, and sets 'option thin true' or 'option thin false' depending
> on the value and calls strbuf_set_helper_option() to send it out.
> 
> It is a bit surprising that there is absolutely nothing else that needs
> to be added to support the option, but given that this was about
> resurrecting a feature that already exists but was left castrated due to
> a historical mistake, it is an understandable confusion on the reader's
> side ;-)
> 
> Looking good.
> 
> Thanks.
>

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

User Julian Maurin <julian.maurin.dev@proton.me> has been added to the cc: list.

@JulianMaurin

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

Submitted as pull.2328.v2.git.1795684746909.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2328/JulianMaurin/push-no-thin-over-http-v2

To fetch this version to local tag pr-2328/JulianMaurin/push-no-thin-over-http-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2328/JulianMaurin/push-no-thin-over-http-v2

@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

This branch is now known as jm/remote-curl-no-thin.

@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

This patch series is no longer integrated into seen.

@gitgitgadget gitgitgadget Bot removed the seen label Nov 26, 2026
@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Julian Maurin via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Julian Maurin <julian.maurin.dev@proton.me>
>
> "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.

Incorporating this use case into the commit message makes the motivation
immediately clear.

In builtin/pack-objects.c:cmd_pack_objects(), creating a thin pack in a
shallow repository passes --objects-edge-aggressive to the internal
rev-list walk, which visits trees of boundary commits; dropping --thin
switches to --objects and avoids those lazy promisor fetches.

Will replace.  Let me mark the topic as ready for 'next' unless somebody
objects (but I suspect that the rest of this week is relatively slow, so
I'll wait for a bit longer than usual).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants