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

Re: [PATCH 2/2] config: allow specifying config entries via envvar pairs

From
Jeff King <peff@peff.net>
Date
Nov 17, 2020, 23:57 UTC
Message-ID
<20201117235736.GC642410@coredump.intra.peff.net>
In-Reply-To
<873618f4he.fsf@evledraar.gmail.com>
On Tue, Nov 17, 2020 at 03:22:05PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 19 quoted lines
> > then I'd feel comfortable making it a public-facing feature. And for
> > most cases it would be pretty pleasant to use (and for the unpleasant
> > ones, I'm not sure that a little quoting is any worse than the paired
> > environment variables found here).
> 
> I wonder if something like the git config -z format wouldn't be easier,
> with the twist that we'd obviously not support \0. So we'd need an
> optional length prefix. : = unspecified.
> 
>     :user.name
>     Jeff K
>     :alias.ci
>     commit
>     :10:bin.ary
>     <10 byte string, might have a \n>
>     :other.key
>     Other Value
> 
> Maybe that's overly fragile, or maybe another format would be better.

Yeah, length-delimited strings are an alternative that some people think is less error-prone than quoting. And we do use pkt-lines. They're also a pain for humans to write (it's nicer if they're optional, but when you _do_ have to start using them, now you are stuck counting things up).

Show 10 quoted lines
> I was trying to come up with one where the common case wouldn't
> require knowing about shell quoting/unquoting, and where you could
> still do:
> 
>     GIT_CONFIG_PARAMETERS=":my.new\nvalue\n$GIT_CONFIG_PARAMETERS"
> 
> Or equivalent, and still just keep $GIT_CONFIG_PARAMETERS as-is to pass
> it along.
> 
> Your "do not require quoting" accomplishes that, and it's arguably a lot

Looks like your mail got cut off. But yeah, the goal of making the quoting optional was to make it easier for humans to use for simple cases. It doesn't help at all with other programs inserting values, which can just as easily err on the side of caution.

BTW, there is another problem with GIT_CONFIG_PARAMETERS (and "git -c" in general). The dotted config-key format:

  section.subsection.key

is unambiguous by itself, even though "subsection" can contain arbitrary bytes, including dots. Because neither "section" nor "key" can contain dots, we can parse from either end, and take the whole middle as a subsection (and this is how we do it in the code).

But an assignment string like:
  section.subsection.key=value

_is_ ambiguous. We have to parse left-to-right up to the first equals (since "value" can contain arbitrary characters, including an equals). But "subsection" can have one, too, so we want to parse right-to-left there. E.g., in:

  one.two=three.four=five
this could be either of:
  - section is "one", key is "two", value is "three.four=five"
  - section is "one", subsection is "two=three", key is "four", value is
    "five"

We currently always parse it as the former (which I think is least-bad of the two, since values are more likely than subsections to contain arbitrary text with an equals).

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 10 of 27 in “config: allow specifying config entries via envvar pairs”
  1. 0/2 config: allow specifying config entries via envvar pairsPatrick Steinhardt, Nov 13, 2020
  2. 1/2 config: extract function to parse config pairsPatrick Steinhardt, Nov 13, 2020
  3. 2/2 config: allow specifying config entries via envvar pairsPatrick Steinhardt, Nov 13, 2020
  4. Ævar Arnfjörð BjarmasonNov 13, 2020
  5. Junio C HamanoNov 16, 2020
  6. Jeff KingNov 17, 2020
  7. Patrick SteinhardtNov 17, 2020
  8. Jeff KingNov 17, 2020
  9. Ævar Arnfjörð BjarmasonNov 17, 2020
  10. Jeff KingNov 17, 2020
  11. Ævar Arnfjörð BjarmasonNov 18, 2020
  12. brian m. carlsonNov 18, 2020
  13. Jeff KingNov 18, 2020
  14. brian m. carlsonNov 18, 2020
  15. Patrick SteinhardtNov 18, 2020
  16. brian m. carlsonNov 19, 2020
  17. Patrick SteinhardtNov 19, 2020
  18. Junio C HamanoNov 18, 2020
  19. Patrick SteinhardtNov 17, 2020
  20. Junio C HamanoNov 17, 2020
  21. Ævar Arnfjörð BjarmasonNov 18, 2020
  22. Patrick SteinhardtNov 18, 2020
  23. Junio C HamanoNov 18, 2020
  24. Ævar Arnfjörð BjarmasonNov 17, 2020
  25. Philip OakleyNov 13, 2020
  26. Patrick SteinhardtNov 17, 2020
  27. Ævar Arnfjörð BjarmasonNov 13, 2020

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.