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

Re: [PATCH v2 7/8] serve: add support for a "startup" git_config() callback

From
Jeff King <peff@peff.net>
Date
Jul 2, 2021, 21:13 UTC
Message-ID
<YN+BdikYt+lH+L3I@coredump.intra.peff.net>
In-Reply-To
<87o8bkamxb.fsf@evledraar.gmail.com>
On Fri, Jul 02, 2021 at 02:55:38PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 10 quoted lines
> > Sadly I don't think this addresses my "v2 receive-pack" concern. The
> > ls_refs_startup_config() function will get called after we've received a
> > request for "ls-refs", which is good. But:
> 
> I think it does in that you rightly objected to us moving all config to
> such a callback, because for some of it we don't have the information
> needed to look it up yet, we do that in the request handler.
> 
> But for a lot of our config it's fine to do it early, hence "startup"
> config.

So I think your patch is OK, but just to lay out my thinking, it was this. The v2 serve code basically does:

  1. Somebody calls serve().
  2. It reads a capability/operation name, then dispatches to the
     appropriate function.
  3. That function reads operation-specific data, like options.
Your first patch read config at step 1. This one reads at step 2.

But from past discussions, the hide-refs config could only be read (or interpreted) after step 3, because that's when we'd see an option saying "this is for pushing".

So anything except step 3 is "too late". But that doesn't stop us from having some early config and some operation-specific late config.

Show 11 quoted lines
> Yes I've moved the ls-refs handling into the "startup" because /right
> now/ it's only handling fetches, it'll need to be moved out if and when
> we start handling pushes.
> 
> But isn't it going to be obvious that we'll need to do that then? Since
> we'll have the example of upload-pack.c doing that exact thing?
>
> I.e. do you not want to have the "startup config" concept at all, or
> would just prefer to have the ls-refs part of it pre-emotively moved out
> of it in anticipation of handling pushes some day, even if we can do
> that on "startup" now?

Sorry to be so confusing. About halfway through writing my previous email I had realized "well, I guess we can have two phases of config-reading, and that's not so bad". So I'm OK with this direction.

I don't think anything else needs to happen on top of your patch here. The "late" phase for ls-refs config reading already happens totally separately (it's in the git_config(ls_refs_config) call, which is already separate from the ensure_config_read() thing. And your patch leaves that line untouched.

Show 7 quoted lines
> > And then it is a separate thing entirely from your "serve will read
> > config" code. It's arguably more confusing, because now config is read
> > in two places, but that is already true because of this
> > ensure_config_read() thing.
> 
> This suggests to me you'd like to preemptively move it out of "startup",
> correct?
It's already out of the startup, so I think we are OK.

My big question here was: is the concept of "startup config" and "other config we read after seeing the options" too confusing? But probably not.

> I just thought preemptively doing it for "ls-refs" wouldn't be needed,
> since we'd notice in testing such a feature that "do it once" would
> break in obvious ways for multi-requests, especially with the comment
> for the "startup_config" callback explicitly calling out that case.

Yeah, we'd definitely notice. I was just wondering if we'd end up needing to back out these changes to accommodate it. But the two-phase thing solves that.

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Han-Wen Nienhuys
Message 22 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.