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

Re: [PATCH v2] config: reject invalid VAR in 'git -c VAR=VAL command'

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 23, 2017, 07:19 UTC
Message-ID
<xmqqo9xt8jcf.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170223055831.u3yofkby3c56t7l4@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> FWIW, the code looks OK here. It is a shame to duplicate the policy
> found in git_config_parse_key(), though.
>
> I wonder if we could make a master version of that which canonicalizes
> in-place, and then just wrap it for the git_config_parse_key()
> interface. Actually, I guess the function you just wrote _is_ that inner
> function, as long as it learned about the "quiet" flag.

Hmm, I obviously missed an opportunity. I thought about doing a similar thing with the policy in parse-source, but that side didn't seem worth doing, as the config-parse-source callgraph is quite a mess (as it has to parse the .ini like format with line breaks and comments, not the simple "<string>[.<string>].<string>" thing, it cannot quite avoid it), and it needs to take advantage of _some_ policy to parse the pieces.

We could loosen the policy implemented by config-parse-key interface (e.g. change config-parse-source to let anything that begins with a non-whitespace continue to be processed with get_value(), instead of only allowing string that begins with isalpha(); similarly loosen get_value() to allow any non-dot non-space string, not just iskeychar() bytes) and first turn what is read into the simple "<string>[.<string>].<string>" format, and then reuse the new "master" logic to validate. That would allow us to update the "master" logic to make it tighter or looser to some degree, but the source parser still needs to hardcode _some_ policy (e.g. the first level and the last level names begin with a non-space) that allows it to guess what "<string>" pieces the contents being parsed from the .ini looking format meant to express.

But you are right. config-parse-key does have the simpler string that can just be given to the canonicalize thing and we should be able to reuse it.

Previous: Jeff KingNext: Junio C Hamano
Message 35 of 41 in “[BUG] submodule config does not apply to upper case submodules?”
  1. Lars SchneiderFeb 15, 2017
  2. t7400: cleanup "submodule add clone shallow submodule" testLars Schneider, Feb 15, 2017
  3. Stefan BellerFeb 15, 2017
  4. Junio C HamanoFeb 15, 2017
  5. Stefan BellerFeb 15, 2017
  6. Junio C HamanoFeb 15, 2017
  7. Jonathan TanFeb 15, 2017
  8. Junio C HamanoFeb 15, 2017
  9. Junio C HamanoFeb 15, 2017
  10. Stefan BellerFeb 15, 2017
  11. Junio C HamanoFeb 15, 2017
  12. Stefan BellerFeb 15, 2017
  13. Junio C HamanoFeb 15, 2017
  14. Jeff KingFeb 16, 2017
  15. Jonathan TanFeb 15, 2017
  16. Junio C HamanoFeb 16, 2017
  17. config: preserve <subsection> case for one-shot config on the command lineJunio C Hamano, Feb 15, 2017
  18. Lars SchneiderFeb 16, 2017
  19. Junio C HamanoFeb 16, 2017
  20. Jeff KingFeb 16, 2017
  21. Junio C HamanoFeb 17, 2017
  22. Junio C HamanoFeb 20, 2017
  23. Lars SchneiderFeb 20, 2017
  24. Jeff KingFeb 21, 2017
  25. Junio C HamanoFeb 21, 2017
  26. config: preserve <subsection> case for one-shot config on the command lineJunio C Hamano, Feb 21, 2017
  27. Jeff KingFeb 21, 2017
  28. Stefan BellerFeb 21, 2017
  29. config: reject invalid VAR in 'git -c VAR=VAL command'Junio C Hamano, Feb 21, 2017
  30. Stefan BellerFeb 21, 2017
  31. Junio C HamanoFeb 21, 2017
  32. config: reject invalid VAR in 'git -c VAR=VAL command'Junio C Hamano, Feb 21, 2017
  33. Junio C HamanoFeb 22, 2017
  34. Jeff KingFeb 23, 2017
  35. Junio C HamanoFeb 23, 2017
  36. Junio C HamanoFeb 23, 2017
  37. Jeff KingFeb 24, 2017
  38. Junio C HamanoFeb 24, 2017
  39. Jeff KingFeb 24, 2017
  40. Junio C HamanoFeb 24, 2017
  41. Jeff KingFeb 24, 2017

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.