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

Re: git should not use a default user.email config value

From
Jeff King <peff@peff.net>
Date
Aug 14, 2013, 07:40 UTC
Message-ID
<20130814074035.GB5095@sigill.intra.peff.net>
In-Reply-To
<vpqsiycn33b.fsf@anie.imag.fr>
On Wed, Aug 14, 2013 at 09:28:24AM +0200, Matthieu Moy wrote:
Show 17 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > Jeff King <peff@peff.net> writes:
> >
> >> I guess we could do something like:
> >>
> >>   [include "repo:...your regex here..."]
> >>     path = .gitconfig-only-for-some-repos
> >>   [include "env:USE_MY_MAGIC_CONFIG"]
> >>     path = .gitconfig-only-when-magic-env-set
> >
> > I am not sure if "env" is very useful, but there certainly are other
> > possibilities (e.g. apply this only on this host, only for members
> > of this UNIX group, etc.)
> 
> I have already wished I had "git version >= XXX" here (but that's tricky
> to implement).

I assume it is "because version XXX understands config option Y, but older versions do not"[1]. Rather than ask for version XXX, then, you could ask for

  [include "option:Y"]
    path = ...

and versions which understand Y (which happens to be XXX or greater) would internally know that and consider the conditional true.

This whole discussion is basically implementing conditional config. In my patch, the conditional is limited only to including other config. But if you have many such conditions (and especially if each one only has one varying config key), the result can be unwieldy. Another way of doing this would be to introduce a conditional syntax to ignore or respect some part of the file. The problem is that it would be tricky to do in a backwards-compatible way.

-Peff
[1] I used to run into this with pager.*, which originally could only be
    a bool, but later learned to take custom pagers. I solved it with:
      git config --file .gitconfig-pager pager.diff ...
      git config --global include.path .gitconfig-pager
    which does not need a version or option conditional, because the
    option was added _before_ the include feature. IOW, older versions
    of git ignore it, and any which actually respect the include will
    know how to handle custom pagers. But that does not work with
    changes that came after the include feature was added. :)
Previous: Matthieu MoyNext: Matthieu Moy
Message 34 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.