git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/5] serve: add support for a git_config() callback

From
Jeff King <peff@peff.net>
Date
Jun 16, 2021, 16:22 UTC
Message-ID
<YMolS8iJAMgbbg9D@coredump.intra.peff.net>
In-Reply-To
<patch-5.5-c8625025125-20210616T141332Z-avarab@gmail.com>
On Wed, Jun 16, 2021 at 04:16:21PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 16 quoted lines
> Since the introduction of serve.c we've added git_config() callbacks
> and other config reading for capabilities in the following commits:
> 
> - e20b4192a37 (upload-pack: support hidden refs with protocol v2, 2018-12-18)
> - 59e1205d167 (ls-refs: report unborn targets of symrefs, 2021-02-05)
> - 6b5b6e422ee (serve: advertise session ID in v2 capabilities, 2020-11-11)
> 
> This code can be simplified by simply adding support to serve.c itself
> for reading config at the right time before the capability is
> called. In particular the ensure_config_read() function being gone
> makes this whole thing much simpler.
> 
> A behavior change here is that we're eagerly doing the configuration
> for all our capabilities regardless of which one we end up serving,
> whereas before we'd defer it until the point where we were processing
> the specific command.

Hmm. I like simplifying things, but what's the plan for when we have a v2 receive-pack? We'll need different config based on whether we're serving a fetch or a push.

While working on e20b4192a37, I had originally proposed patches that would pass that context into the serve mechanism (based on whether we were called by upload-pack or receive-pack). But the review there indicated that v2 receive-pack would probably involve an extra capability argument passed by the client to ls-refs.

So we'd eventually need to parse config _after_ we've received the actual ls-refs command. To be clear, this patch isn't breaking anything now. But I think it's painting us into a corner that we'll regret later.

Of course there are ways around this. E.g., we could read config for both operations ahead of time, and then decide which to use later. But that definitely isn't how it works now, and we'd have to refactor the whole ref_is_hidden() system to fix that. Definitely do-able, but given the relatively limited upside of this patch, I'm not sure if it's worth it.

I'd also note that this patch doesn't touch upload_pack_v2() at all, which also reads config. That one is extra-weird because it reads the config fresh for every round of interaction with the client, and then cleans it up. Which led to fixes like the one in 08450ef791 (upload-pack: clear filter_options for each v2 fetch command, 2020-05-08).

Doing a single config read would probably make that simpler. But the config setup is shared between the v0 and v2 functions, so extracting it into serve() would potentially be awkward.

> In particular the ensure_config_read() function being gone
> makes this whole thing much simpler.

I do agree this is awkward. The two calls for that function seem to come from the "should we advertise ls-refs" and "actually do ls-refs" functions. Should we be able to assume that the former ran if we are in the latter? I'm not sure if that's true or not (i.e., because it's rare but possible for a client to make two separate HTTP requests, one to discover our v2 capabilities and another to actually issue ls-refs).

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 8 of 58 in “serve: add "configure" callback”
  1. 0/5 serve: add "configure" callbackÆvar Arnfjörð Bjarmason, Jun 16, 2021
  2. 1/5 serve: mark has_capability() as staticÆvar Arnfjörð Bjarmason, Jun 16, 2021
  3. Eric SunshineJun 16, 2021
  4. Junio C HamanoJun 17, 2021
  5. 2/5 transport: rename "fetch" in transport_vtable to "fetch_refs"Ævar Arnfjörð Bjarmason, Jun 16, 2021
  6. 3/5 transport: use designated initializersÆvar Arnfjörð Bjarmason, Jun 16, 2021
  7. 5/5 serve: add support for a git_config() callbackÆvar Arnfjörð Bjarmason, Jun 16, 2021
  8. Jeff KingJun 16, 2021
  9. 4/5 serve: use designated initializersÆvar Arnfjörð Bjarmason, Jun 16, 2021
  10. Jeff KingJun 16, 2021
  11. Junio C HamanoJun 17, 2021
  12. 0/8 serve: add "startup_config" callbackÆvar Arnfjörð Bjarmason, Jun 28, 2021
  13. 1/8 serve: mark has_capability() as staticÆvar Arnfjörð Bjarmason, Jun 28, 2021
  14. 3/8 transport: use designated initializersÆvar Arnfjörð Bjarmason, Jun 28, 2021
  15. 2/8 transport: rename "fetch" in transport_vtable to "fetch_refs"Ævar Arnfjörð Bjarmason, Jun 28, 2021
  16. 5/8 serve.c: add call_{advertise,command}() indirectionÆvar Arnfjörð Bjarmason, Jun 28, 2021
  17. 4/8 serve: use designated initializersÆvar Arnfjörð Bjarmason, Jun 28, 2021
  18. 7/8 serve: add support for a "startup" git_config() callbackÆvar Arnfjörð Bjarmason, Jun 28, 2021
  19. Jeff KingJul 1, 2021
  20. Jeff KingJul 1, 2021
  21. Ævar Arnfjörð BjarmasonJul 2, 2021
  22. Jeff KingJul 2, 2021
  23. Han-Wen NienhuysJul 5, 2021
  24. Han-Wen NienhuysJul 5, 2021
  25. 6/8 serve.c: add trace2 regions for advertise & commandÆvar Arnfjörð Bjarmason, Jun 28, 2021
  26. Jeff KingJul 1, 2021
  27. Ævar Arnfjörð BjarmasonJul 2, 2021
  28. Han-Wen NienhuysJul 5, 2021
  29. 8/8 upload-pack.c: convert to new serve.c "startup" config cbÆvar Arnfjörð Bjarmason, Jun 28, 2021
  30. Han-Wen NienhuysJul 5, 2021
  31. 00/12 serve.[ch]: general API cleanupÆvar Arnfjörð Bjarmason, Jul 21, 2021
  32. 01/12 serve: mark has_capability() as staticÆvar Arnfjörð Bjarmason, Jul 21, 2021
  33. 02/12 transport: rename "fetch" in transport_vtable to "fetch_refs"Ævar Arnfjörð Bjarmason, Jul 21, 2021
  34. 03/12 transport: use designated initializersÆvar Arnfjörð Bjarmason, Jul 21, 2021
  35. 04/12 serve: use designated initializersÆvar Arnfjörð Bjarmason, Jul 21, 2021
  36. 05/12 serve.c: add call_{advertise,command}() indirectionÆvar Arnfjörð Bjarmason, Jul 21, 2021
  37. 06/12 serve: add support for a "startup" git_config() callbackÆvar Arnfjörð Bjarmason, Jul 21, 2021
  38. 07/12 serve.c: move version line to advertise_capabilities()Ævar Arnfjörð Bjarmason, Jul 21, 2021
  39. 08/12 serve.[ch]: remove "serve_options", split up --advertise-refs codeÆvar Arnfjörð Bjarmason, Jul 21, 2021
  40. 10/12 upload-pack: document and rename --advertise-refsÆvar Arnfjörð Bjarmason, Jul 21, 2021
  41. 09/12 {upload,receive}-pack tests: add --advertise-refs testsÆvar Arnfjörð Bjarmason, Jul 21, 2021
  42. fixup! {upload,receive}-pack tests: add --advertise-refs testsCarlo Marcelo Arenas Belón, Aug 3, 2021
  43. 11/12 upload-pack.c: convert to new serve.c "startup" config cbÆvar Arnfjörð Bjarmason, Jul 21, 2021
  44. 12/12 serve.[ch]: don't pass "struct strvec *keys" to commandsÆvar Arnfjörð Bjarmason, Jul 21, 2021
  45. Josh SteadmonAug 2, 2021
  46. 00/10 serve.[ch]: general API cleanup + --advertise-refs cleanupÆvar Arnfjörð Bjarmason, Aug 5, 2021
  47. 01/10 serve: mark has_capability() as staticÆvar Arnfjörð Bjarmason, Aug 5, 2021
  48. 02/10 transport: rename "fetch" in transport_vtable to "fetch_refs"Ævar Arnfjörð Bjarmason, Aug 5, 2021
  49. 03/10 transport: use designated initializersÆvar Arnfjörð Bjarmason, Aug 5, 2021
  50. 04/10 serve: use designated initializersÆvar Arnfjörð Bjarmason, Aug 5, 2021
  51. 05/10 serve.[ch]: don't pass "struct strvec *keys" to commandsÆvar Arnfjörð Bjarmason, Aug 5, 2021
  52. 06/10 serve: move transfer.advertiseSID check into session_id_advertise()Ævar Arnfjörð Bjarmason, Aug 5, 2021
  53. 07/10 serve.c: move version line to advertise_capabilities()Ævar Arnfjörð Bjarmason, Aug 5, 2021
  54. 08/10 {upload,receive}-pack tests: add --advertise-refs testsÆvar Arnfjörð Bjarmason, Aug 5, 2021
  55. 09/10 serve.[ch]: remove "serve_options", split up --advertise-refs codeÆvar Arnfjörð Bjarmason, Aug 5, 2021
  56. Derrick StoleeAug 24, 2021
  57. 10/10 upload-pack: document and rename --advertise-refsÆvar Arnfjörð Bjarmason, Aug 5, 2021
  58. Derrick StoleeAug 24, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.