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

conditional config syntax

From
Jeff King <peff@peff.net>
Date
Aug 14, 2013, 14:08 UTC
Message-ID
<20130814140853.GA32605@sigill.intra.peff.net>
In-Reply-To
<CAPc5daWqzTkMFkecrAjMCmxwZZrgUtB-FVKrjsmfvpgwPgF8AA@mail.gmail.com>
[updated subject, as we are very far off the original topic]
On Wed, Aug 14, 2013 at 07:00:58AM -0700, Junio C Hamano wrote:
Show 20 quoted lines
> > > This whole discussion is basically implementing conditional config.
> > > [...] The problem is that it would be tricky to do in a
> > > backwards-compatible way.
> >
> > That could be done with "conditional comments" like
> >
> > # if <some-condition> then
> > [core]
> >         pager = less
> > # endif
> >
> > That's rather ugly, and the implementation would be even more ugly, but
> > backward-compatible.
> 
> I highly doubt that you would want to be "backward compatible" in this
> case, though.  The section of the configuration you are enclosing the
> new if/endif syntax may be understood only by newer Git (e.g. imagine
> core.pager is still bool-only today), and older Git that do not
> understand if/endif syntax will happily read that section and choke on
> it, no?

I would think the ideal behavior would be for existing implementations to just not include the conditional section.

If we take the conditional by default in existing versions of git (i.e., the behavior of Matthieu's proposal), then any "do this only if version X or greater" conditional is going to be inconsistent (it will be true for old versions, not true for versions which understand conditionals but pre-date X, and then true again for the actual versions you want).

Likewise, if we introduce some new non-backwards-compatible syntax that existing Git chokes on, then you have created a new compatibility problem. You cannot use older versions of git, which is the exact problem a version conditional is trying to solve.

That is one of the reasons that include.path is designed as it is; old versions accept it and do nothing (unless you specifically ask for it as a value). And likewise, include.*.path will do nothing for existing versions of git.

Or hmm. Maybe that is what you mean by "choke on it". Choke on the invalid config, not on the new syntax.

-Peff
Previous: Matthieu MoyNext: Junio C Hamano
Message 38 of 46 in “Re: git should not use a default user.email config value”
  1. Jonathan NiederAug 9, 2013
  2. Thorsten GlaserAug 9, 2013
  3. Felipe ContrerasAug 9, 2013
  4. Matthieu MoyAug 13, 2013
  5. Jeff KingAug 9, 2013
  6. Junio C HamanoAug 9, 2013
  7. Jeff KingAug 10, 2013
  8. Jonathan NiederAug 10, 2013
  9. Jeff KingAug 10, 2013
  10. Jonathan NiederAug 10, 2013
  11. Jeff KingAug 10, 2013
  12. Jonathan NiederAug 9, 2013
  13. Jeff KingAug 10, 2013
  14. Michael HaggertyAug 10, 2013
  15. Jeff KingAug 10, 2013
  16. Michael HaggertyAug 10, 2013
  17. Thorsten GlaserAug 10, 2013
  18. Andreas SchwabAug 10, 2013
  19. Greg TroxelAug 12, 2013
  20. Junio C HamanoAug 10, 2013
  21. Andrew ArdillAug 12, 2013
  22. Jeff KingAug 12, 2013
  23. Michael HaggertyAug 12, 2013
  24. Jeff KingAug 12, 2013
  25. Andrew ArdillAug 12, 2013
  26. Jeff KingAug 12, 2013
  27. Andrew ArdillAug 13, 2013
  28. Jeff KingAug 13, 2013
  29. Jeff KingAug 13, 2013
  30. Andrew ArdillAug 13, 2013
  31. Jeff KingAug 13, 2013
  32. Junio C HamanoAug 13, 2013
  33. Matthieu MoyAug 14, 2013
  34. Jeff KingAug 14, 2013
  35. Matthieu MoyAug 14, 2013
  36. Junio C HamanoAug 14, 2013
  37. Matthieu MoyAug 14, 2013
  38. conditional config syntaxJeff King, Aug 14, 2013
  39. Junio C HamanoAug 14, 2013
  40. Michael HaggertyAug 14, 2013
  41. Jeff KingAug 14, 2013
  42. Junio C HamanoAug 13, 2013
  43. Matthieu MoyAug 13, 2013
  44. Aaron SchrabAug 11, 2013
  45. Matthieu MoyAug 13, 2013
  46. Thorsten GlaserAug 13, 2013

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.