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

Re: [PATCH v6 2/2] config: include file if remote URL matches a glob

From
Glen Choo <chooglen@google.com>
Date
Dec 9, 2021, 23:33 UTC
Message-ID
<kl6l8rwt9ww2.fsf@chooglen-macbookpro.roam.corp.google.com>
In-Reply-To
<20211209223919.513113-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 46 quoted lines
>> > +`hasconfig:remote.*.url:`::
>> > +	The data that follows this keyword is taken to
>> > +	be a pattern with standard globbing wildcards and two
>> > +	additional ones, `**/` and `/**`, that can match multiple
>> > +	components. The first time this keyword is seen, the rest of
>> > +	the config files will be scanned for remote URLs (without
>> > +	applying any values). If there exists at least one remote URL
>> > +	that matches this pattern, the include condition is met.
>> > ++
>> > +Files included by this option (directly or indirectly) are not allowed
>> > +to contain remote URLs.
>> 
>> Wondering out loud.. Reading this and Ævar's comment [1], I wonder if we
>> should make it clear to users *why* we choose to forbid remote URLs.
>> 
>> Since this series is setting a precedent for future "hasconfig:"
>> conditions (files included by "hasconfig:foo.*.bar" cannot contain any
>> "foo.*.bar" values), it would be useful to git developers to explain
>> *why* we chose to do this. And if we're documenting it for ourselves,
>> we might as well write it in the public docs. That way, users would know
>> that this is more of a guardrail (because it's simpler to understand
>> this way) than a hard limitation.
>> 
>> [1] https://lore.kernel.org/git/211207.86k0ggnvfo.gmgdl@evledraar.gmail.com
>
> The explanation is rather long, though. It goes something like this:
>
>   If the main config is:
>
>   [remote a]
>     url = bar
>   [includeif hasconfig:remote.*.url:foo]
>     path = foo
>   [includeif hasconfig:remote.*.url:bar]
>     path = bar
>
>   and "bar" contains:
>
>   [remote b]
>     url = foo
>
>   Should "foo" be included? For now, we avoid these situations
>   completely by prohibiting URLs from being configured in "includeif
>   hasconfig".
>
> If you can think of a concise explanation, maybe we can include it.

Yeah, I can't think of a concise-yet-clear way to convey this to users (if I had thought of one, I wouldn't have prefaced my original comment with "Wondering out loud").

Spitballing here...
  `hasconfig:remote.*.url:`::
    The data that follows this keyword is taken to
    be a pattern with standard globbing wildcards and two
    additional ones, `**/` and `/**`, that can match multiple
    components. The first time this keyword is seen, the rest of
    the config files will be scanned for remote URLs (without
    applying any values). If there exists at least one remote URL
    that matches this pattern, the include condition is met.
  - Files included by this option (directly or indirectly) are not allowed
  - to contain remote URLs.
  + Because new remote URLs might affect the correctness of the include
  + condition, files included by this option (directly or indirectly) are
  + not allowed to contain remote URLs.

Although, upon further reflection, I wonder if this approach of banning config variables really gives us the safety we want after all. Reworking your example, say we expand "hasconfig" to include "hasconfig:branch.*.merge" then we can have this in the main config:

   [remote a]
     url = baz
   [branch c]
     merge = bar
   [includeif hasconfig:remote.*.url:foo]
     path = foo
   [includeif hasconfig:branch.*.merge:bar]
     path = bar
and "bar" contains:
   [remote b]
     url = foo

we end up with the exact same question of "Should "foo" be included?". This shows that the rule isn't actually "files included by hasconfig:remote.*.url cannot include remote.*.url", but the much more restrictive "files included by hasconfig:<anything> cannot include any config values that can appear in hasconfig". This sounds pretty unusable to me..

But I think that with the semantics you've defined, we don't really need to forbid config variables. This section describes:

  The first time this keyword is seen, the rest of the config files will
  be scanned for remote URLs (without applying any values). If there
  exists at least one remote URL that matches this pattern, the include
  condition is met.

which, to me, gives us a pass to say "the first time we see a hasconfig, we will do an additional scan without applying values". That doesn't sound _too_ confusing to me, but I don't know how it looks to someone with fresh eyes.

Forgive me if this exact suggestion came up before on-list (I know we've discussed this exact approach off-list).

Previous: Jonathan TanNext: Jonathan Tan
Message 68 of 87 in “Conditional config includes based on remote URL”
  1. 0/2 Conditional config includes based on remote URLJonathan Tan, Oct 12, 2021
  2. 1/2 config: make git_config_include() staticJonathan Tan, Oct 12, 2021
  3. Jeff KingOct 12, 2021
  4. Junio C HamanoOct 12, 2021
  5. Ævar Arnfjörð BjarmasonOct 13, 2021
  6. Junio C HamanoOct 13, 2021
  7. Jonathan TanOct 13, 2021
  8. 2/2 config: include file if remote URL matches a globJonathan Tan, Oct 12, 2021
  9. Jeff KingOct 12, 2021
  10. Jonathan TanOct 13, 2021
  11. Jeff KingOct 27, 2021
  12. Jonathan TanOct 27, 2021
  13. Junio C HamanoOct 12, 2021
  14. Jonathan TanOct 13, 2021
  15. brian m. carlsonOct 13, 2021
  16. Jonathan TanOct 13, 2021
  17. Jonathan TanOct 18, 2021
  18. Emily ShafferOct 22, 2021
  19. Jeff KingOct 27, 2021
  20. Jonathan TanOct 27, 2021
  21. Jeff KingOct 27, 2021
  22. Ævar Arnfjörð BjarmasonOct 25, 2021
  23. Jonathan TanOct 25, 2021
  24. Ævar Arnfjörð BjarmasonOct 26, 2021
  25. 0/2 Conditional config includes based on remote URLJonathan Tan, Oct 29, 2021
  26. 1/2 config: make git_config_include() staticJonathan Tan, Oct 29, 2021
  27. Emily ShafferNov 5, 2021
  28. 2/2 config: include file if remote URL matches a globJonathan Tan, Oct 29, 2021
  29. Emily ShafferNov 5, 2021
  30. Ævar Arnfjörð BjarmasonNov 6, 2021
  31. Jonathan TanNov 9, 2021
  32. Jonathan TanNov 9, 2021
  33. 0/2 Conditional config includes based on remote URLJonathan Tan, Nov 16, 2021
  34. 1/2 config: make git_config_include() staticJonathan Tan, Nov 16, 2021
  35. 2/2 config: include file if remote URL matches a globJonathan Tan, Nov 16, 2021
  36. Glen ChooNov 22, 2021
  37. Jonathan TanNov 29, 2021
  38. Junio C HamanoNov 23, 2021
  39. Jonathan TanNov 29, 2021
  40. Junio C HamanoDec 1, 2021
  41. Jonathan TanDec 2, 2021
  42. Ævar Arnfjörð BjarmasonNov 23, 2021
  43. Jonathan TanNov 29, 2021
  44. Ævar Arnfjörð BjarmasonNov 29, 2021
  45. 0/2 Conditional config includes based on remote URLJonathan Tan, Nov 29, 2021
  46. 1/2 config: make git_config_include() staticJonathan Tan, Nov 29, 2021
  47. Ævar Arnfjörð BjarmasonNov 29, 2021
  48. Junio C HamanoNov 30, 2021
  49. 2/2 config: include file if remote URL matches a globJonathan Tan, Nov 29, 2021
  50. Junio C HamanoDec 2, 2021
  51. Jonathan TanDec 2, 2021
  52. 0/2 Conditional config includes based on remote URLJonathan Tan, Dec 2, 2021
  53. 1/2 config: make git_config_include() staticJonathan Tan, Dec 2, 2021
  54. 2/2 config: include file if remote URL matches a globJonathan Tan, Dec 2, 2021
  55. Glen ChooDec 6, 2021
  56. Jonathan TanDec 7, 2021
  57. Ævar Arnfjörð BjarmasonDec 6, 2021
  58. Jonathan TanDec 7, 2021
  59. Ævar Arnfjörð BjarmasonDec 7, 2021
  60. Jonathan TanDec 7, 2021
  61. 0/2 Conditional config includes based on remote URLJonathan Tan, Dec 7, 2021
  62. 1/2 config: make git_config_include() staticJonathan Tan, Dec 7, 2021
  63. 2/2 config: include file if remote URL matches a globJonathan Tan, Dec 7, 2021
  64. Glen ChooDec 8, 2021
  65. Jonathan TanDec 9, 2021
  66. Glen ChooDec 8, 2021
  67. Jonathan TanDec 9, 2021
  68. Glen ChooDec 9, 2021
  69. Jonathan TanDec 13, 2021
  70. Junio C HamanoDec 10, 2021
  71. Jonathan TanDec 13, 2021
  72. 0/2 Conditional config includes based on remote URLJonathan Tan, Dec 14, 2021
  73. 1/2 config: make git_config_include() staticJonathan Tan, Dec 14, 2021
  74. 2/2 config: include file if remote URL matches a globJonathan Tan, Dec 14, 2021
  75. Glen ChooDec 16, 2021
  76. Elijah NewrenDec 28, 2021
  77. Jonathan TanJan 10, 2022
  78. Glen ChooDec 16, 2021
  79. Elijah NewrenDec 28, 2021
  80. Glen ChooDec 28, 2021
  81. Jonathan TanJan 10, 2022
  82. Elijah NewrenJan 10, 2022
  83. Scalar vs JGit, was Re: [PATCH v7 0/2] Conditional config includes based on remote URLJohannes Schindelin, Jan 25, 2022
  84. 0/2 Conditional config includes based on remote URLJonathan Tan, Jan 18, 2022
  85. 1/2 config: make git_config_include() staticJonathan Tan, Jan 18, 2022
  86. 2/2 config: include file if remote URL matches a globJonathan Tan, Jan 18, 2022
  87. Elijah NewrenJan 18, 2022

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.