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

Re: config-file includes

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Sep 26, 2011, 10:45 UTC
Message-ID
<CACsJy8BAVRAct=sxTpZ+b-ft1OjbY9oZG6uEXrcsTXw3CXnwSg@mail.gmail.com>
In-Reply-To
<20110923195829.GA27677@sigill.intra.peff.net>
On Sat, Sep 24, 2011 at 5:58 AM, Jeff King <peff@peff.net> wrote:
Show 21 quoted lines
> Here's one solution I've given a little thought to. Comments welcome.
>
> I've sometimes wanted an "include" mechanism in git config files.
> Partially to just keep things tidier, partially to avoid
> cutting-and-pasting between some repo-specific config, and partially
> because I'd like a conditional inclusion mechanism[1]. I was thinking of
> something that would be syntactically compatible but semantically
> meaningless in current versions of git, like:
>
>  [include]
>  path = /some/file
>  path = /some/other/file
>  path = ~/some/file/in/your/homedir
>
> You could extend this to look in refs, with something like:
>
>  [include]
>  ref = meta:config
>
> which would resolve meta:config to a blob and examine it (i.e., it would
> look at refs/heads/meta).

I had something similar [1], although I disregarded worktree content completely. One thing about this meta thing is fsck/prune must dig in config file in order not to accidentally remove something config file refers to.

Another thing is, what if I want to exclude certain part of the included config?
[1] http://thread.gmane.org/gmane.comp.version-control.git/163285/focus=163288
Show 11 quoted lines
> [1] I want conditional inclusion because sometimes the rules for config
>    entries changes from version to version. For example, I have
>    pager.diff set to a script in my ~/.gitconfig. But older versions of
>    git don't understand non-boolean values and barf. I'd really like to
>    do something like:
>
>    [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?
-- 
Duy
Previous: Jeff KingNext: Jeff King
Message 2 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.