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

Re: config-file includes

From
Jeff King <peff@peff.net>
Date
Sep 26, 2011, 20:05 UTC
Message-ID
<20110926200553.GA492@sigill.intra.peff.net>
In-Reply-To
<20110926192126.GA55743@gmail.com>
On Mon, Sep 26, 2011 at 09:21:27PM +0200, David Aguilar wrote:
Show 14 quoted lines
> > >    [include-ifdef "has-pager-scripts"]
> > >    path = ~/.gitconfig-pager
> > >
> > >    where "has-pager-scripts" would be a magic flag compiled into git
> > >    versions that understand that config.
> > 
> > But how far would you go with conditional expressions?
> 
> This syntax is simple yet would solve one problem I run into
> often.  It could be used for the case where some settings
> (e.g. diff.tool, merge.tool) are different on OS X and Linux.
> 
> [include-ifdef "darwin"]
> 	path = ~/.gitconfig-darwin
Thanks for another concrete example.

I'm not sure how that would be implemented, though. I don't think git knows that it is compiled for darwin. Would it just be running "uname -s" behind the scenes? Should it happen at runtime, or as part of the compile process?

We could allow arbitrary shell code like:
  [include-if "test `uname -s` -eq Darwin"]

Very flexible, though it makes me think we are getting a little overboard. And it's an extra shell invocation whenever we read the config, which is ugly.

-Peff
Previous: David AguilarNext: Junio C Hamano
Message 5 of 8 in “config-file includes”
  1. Jeff KingSep 23, 2011
  2. Nguyen Thai Ngoc DuySep 26, 2011
  3. Jeff KingSep 26, 2011
  4. David AguilarSep 26, 2011
  5. Jeff KingSep 26, 2011
  6. Junio C HamanoSep 26, 2011
  7. Jay SoffianSep 27, 2011
  8. Jeff KingSep 27, 2011

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.