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 27, 2011, 02:38 UTC
Message-ID
<20110927023845.GC6920@sigill.intra.peff.net>
In-Reply-To
<CAG+J_Dw3B0qReTevph725sPatpKDzikC=W0XTvKo4GsYLVcL4w@mail.gmail.com>
On Mon, Sep 26, 2011 at 10:13:44PM -0400, Jay Soffian wrote:
Show 10 quoted lines
> > 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.
> 
> I would think git could just learn a few useful defines at the time of
> compile, such as e.g. OS_Darwin would be more than sufficient.

Yeah, I think that is probably more sane. We don't collect the information now, but it probably wouldn't be that hard (at the very worst, it would probably just involve running "uname" at build time).

Show 6 quoted lines
> I can also give you another use use case. I keep all my work repos
> under ~Work/ and I want my user.email on all those to be my work email
> addy, and all other repos on my system I want to use my personal email
> address. So my ~/.gitconfig has my personal email address and then 99%
> of the time I forget to configure the repos under ~/Work correctly.
> That said, I'm not sure how the config include would help this...

You would need to provide git with some condition about which address should be used. It sounds like the repo directory is the best bet. So maybe something like:

  [include-ifrepo "/home/jsoffian/Work/*"]
or something. Maybe that's too gross. I dunno.
FWIW, this hack would work even with current git:
  cat >bin/git <<\EOF
  #!/bin/sh
  case "`git rev-parse --show-toplevel`" in
  "$HOME/Work/*")
          set -- -c user.email=whatever "$@"
          ;;
  esac
  exec /path/to/real/git "$@"
  EOF

which would actually work with most of the conditionals that have been mentioned in this thread. But it's kind of nasty.

-Peff
Previous: Jay Soffian
Message 8 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.