mbox series

[0/4] some v2 capability advertisement cleanups

Message ID 20240228224625.GA1158651@coredump.intra.peff.net (mailing list archive)
Headers show
Series some v2 capability advertisement cleanups | expand

Message

Jeff King Feb. 28, 2024, 10:46 p.m. UTC
While working on another series, I noticed that upload-pack will accept
the "packfile-uris" directive even if we didn't advertise it. That's not
a huge deal in practice, but the spec says we're not supposed to. And
while cleaning that up, I noticed a bit of duplication in the existing
advertisement/allow code.

So patches 1-3 clean up the situation a bit, and then patch 4 tightens
up the packfile-uris handling.

There are some small textual conflicts with the series I just posted in:

  https://lore.kernel.org/git/20240228223700.GA1157826@coredump.intra.peff.net/

I'm happy to prepare this on top of that if it's easier.

  [1/4]: upload-pack: use repository struct to get config
  [2/4]: upload-pack: centralize setup of sideband-all config
  [3/4]: upload-pack: use existing config mechanism for advertisement
  [4/4]: upload-pack: only accept packfile-uris if we advertised it

 t/t5702-protocol-v2.sh | 18 +++++++++++++
 upload-pack.c          | 58 +++++++++++++++++++-----------------------
 2 files changed, 44 insertions(+), 32 deletions(-)

-Peff

Comments

Junio C Hamano Feb. 28, 2024, 11:51 p.m. UTC | #1
Jeff King <peff@peff.net> writes:

> There are some small textual conflicts with the series I just posted in:
>
>   https://lore.kernel.org/git/20240228223700.GA1157826@coredump.intra.peff.net/
>
> I'm happy to prepare this on top of that if it's easier.

Thanks for a heads-up.

The other one merged first and then this one does give the
following, which does not look like a huge deal.

diff --cc upload-pack.c
index 281bdf85c9,66f4de9d87..0000000000
--- i/upload-pack.c
+++ w/upload-pack.c
@@@ -113,7 -113,7 +113,8 @@@ struct upload_pack_data 
  	unsigned done : 1;					/* v2 only */
  	unsigned allow_ref_in_want : 1;				/* v2 only */
  	unsigned allow_sideband_all : 1;			/* v2 only */
 +	unsigned seen_haves : 1;				/* v2 only */
+ 	unsigned allow_packfile_uris : 1;			/* v2 only */
  	unsigned advertise_sid : 1;
  	unsigned sent_capabilities : 1;
  };
@@@ -1648,10 -1651,8 +1654,11 @@@ static void process_args(struct packet_
  			continue;
  		}
  
- 		if (skip_prefix(arg, "packfile-uris ", &p)) {
+ 		if (data->allow_packfile_uris &&
+ 		    skip_prefix(arg, "packfile-uris ", &p)) {
 +			if (data->uri_protocols.nr)
 +				send_err_and_die(data,
 +						 "multiple packfile-uris lines forbidden");
  			string_list_split(&data->uri_protocols, p, ',', -1);
  			continue;
  		}
Jeff King Feb. 29, 2024, 12:44 a.m. UTC | #2
On Wed, Feb 28, 2024 at 03:51:34PM -0800, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > There are some small textual conflicts with the series I just posted in:
> >
> >   https://lore.kernel.org/git/20240228223700.GA1157826@coredump.intra.peff.net/
> >
> > I'm happy to prepare this on top of that if it's easier.
> 
> Thanks for a heads-up.
> 
> The other one merged first and then this one does give the
> following, which does not look like a huge deal.

Yep, that matches the resolution I did locally.

-Peff
Patrick Steinhardt March 4, 2024, 7:44 a.m. UTC | #3
On Wed, Feb 28, 2024 at 05:46:25PM -0500, Jeff King wrote:
> While working on another series, I noticed that upload-pack will accept
> the "packfile-uris" directive even if we didn't advertise it. That's not
> a huge deal in practice, but the spec says we're not supposed to. And
> while cleaning that up, I noticed a bit of duplication in the existing
> advertisement/allow code.
> 
> So patches 1-3 clean up the situation a bit, and then patch 4 tightens
> up the packfile-uris handling.

This patch series was really easy to follow and feels like the right
thing to do. I've got a couple of nits, but none of them are important
enough to warrant a reroll.

Thanks!

Patrick

> There are some small textual conflicts with the series I just posted in:
> 
>   https://lore.kernel.org/git/20240228223700.GA1157826@coredump.intra.peff.net/
> 
> I'm happy to prepare this on top of that if it's easier.
> 
>   [1/4]: upload-pack: use repository struct to get config
>   [2/4]: upload-pack: centralize setup of sideband-all config
>   [3/4]: upload-pack: use existing config mechanism for advertisement
>   [4/4]: upload-pack: only accept packfile-uris if we advertised it
> 
>  t/t5702-protocol-v2.sh | 18 +++++++++++++
>  upload-pack.c          | 58 +++++++++++++++++++-----------------------
>  2 files changed, 44 insertions(+), 32 deletions(-)
> 
> -Peff
>
Jeff King March 4, 2024, 10:02 a.m. UTC | #4
On Mon, Mar 04, 2024 at 08:44:56AM +0100, Patrick Steinhardt wrote:

> On Wed, Feb 28, 2024 at 05:46:25PM -0500, Jeff King wrote:
> > While working on another series, I noticed that upload-pack will accept
> > the "packfile-uris" directive even if we didn't advertise it. That's not
> > a huge deal in practice, but the spec says we're not supposed to. And
> > while cleaning that up, I noticed a bit of duplication in the existing
> > advertisement/allow code.
> > 
> > So patches 1-3 clean up the situation a bit, and then patch 4 tightens
> > up the packfile-uris handling.
> 
> This patch series was really easy to follow and feels like the right
> thing to do. I've got a couple of nits, but none of them are important
> enough to warrant a reroll.

Thanks for reviewing. The typos you found are definitely all wrong, but
I think the topic is in 'next' already (and they were all just in the
commit messages).

-Peff