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

Re: [PATCH 1/4] config: add include directive

From
Jens Lehmann <jens.lehmann@web.de>
Date
Jan 27, 2012, 17:03 UTC
Message-ID
<4F22D8EA.6080003@web.de>
In-Reply-To
<20120126225140.GB12855@sigill.intra.peff.net>
Am 26.01.2012 23:51, schrieb Jeff King:
Show 34 quoted lines
> However, I didn't think about the fact that git-submodule.sh would be
> calling git-config separately, and that is accidentally changed by my
> patch.  Even if we changed git-submodule to use "git config
> --no-includes" that would break any third-party scripts that use "git
> config" to read git-like files.
> 
> But it would be nice for callers doing "git config foo.bar" to get the
> includes by default. So maybe the right rule is:
> 
>   1. In C:
>      a. git_config() respects includes automatically.
>      b. other callers do not do so automatically (e.g., gitmodules via
>         submodule.c).
> 
>     (i.e., what is implemented by this patch)
> 
>   2. Callers of git-config:
>      a. respect includes for lookup that checks all of the "normal"
>         config spots in sequence: .git/config, ~/.gitconfig, and
>         /etc/gitconfig. These are the shell equivalent of calling
>         git_config().
> 
>      b. when we are looking in a specific file (via GIT_CONFIG or "git
>         config -f"), do not respect includes (but allow --includes if
>         the caller chooses). This specific file may be something like
>         .gitmodules. Or perhaps somebody is saying "no, I really just
>         want to know what is in _this_ file, not what the config
>         ecosystem tells me in general".
> 
> And then because of 1a and 2a, most programs should Just Work without
> any changes, but because of 1b and 2b, any special uses will have to
> decide manually whether they would want to allow includes.
> 
> Does that make sense?

To me it really does. It lets submodule.c:gitmodules_config and "git config -f .gitmodules" behave in the same way, which is very important for consistent behavior between the submodule script and the submodule functionality that is already handled in c. And I don't know of a use case for includes in .gitmodules (the main reason for adding includes seems to be to enable users to have configuration stored in the repo, which the .gitmodules file already is. And if it is about having out of repo configuration blended in, .gitmodules settings are always overridden by those in .git/config, and you can use includes there).

The only thing I'm not so sure about is the GIT_CONFIG case. I don't know if using this is rather a "I moved my config there, but please respect includes there too" or a "I want git config to look at a completely different file" use case. Probably both. But also the question of where to look for relative paths seems not so easy to answer for the GIT_CONFIG case, so it might be best to just disable includes there too.

Previous: Jeff KingNext: Ævar Arnfjörð Bjarmason
Message 12 of 36 in “config include directives”
  1. 0/4 config include directivesJeff King, Jan 26, 2012
  2. 1/4 config: add include directiveJeff King, Jan 26, 2012
  3. Johannes SixtJan 26, 2012
  4. Jeff KingJan 26, 2012
  5. Junio C HamanoJan 26, 2012
  6. Jeff KingJan 26, 2012
  7. Jeff KingJan 26, 2012
  8. Junio C HamanoJan 26, 2012
  9. Jeff KingJan 26, 2012
  10. Junio C HamanoJan 27, 2012
  11. Jeff KingJan 27, 2012
  12. Jens LehmannJan 27, 2012
  13. Ævar Arnfjörð BjarmasonJan 27, 2012
  14. Jeff KingJan 27, 2012
  15. Ævar Arnfjörð BjarmasonJan 27, 2012
  16. Michael HaggertyJan 27, 2012
  17. Jeff KingJan 27, 2012
  18. 2/4 config: factor out config file stack managementJeff King, Jan 26, 2012
  19. 3/4 config: support parsing config data from buffersJeff King, Jan 26, 2012
  20. 4/4 config: allow including config from repository blobsJeff King, Jan 26, 2012
  21. Johannes SixtJan 26, 2012
  22. Jeff KingJan 26, 2012
  23. Nguyen Thai Ngoc DuyJan 27, 2012
  24. Jeff KingJan 27, 2012
  25. Junio C HamanoJan 26, 2012
  26. Jeff KingJan 26, 2012
  27. Junio C HamanoJan 27, 2012
  28. Jeff KingJan 27, 2012
  29. Junio C HamanoJan 27, 2012
  30. Jeff KingJan 27, 2012
  31. Johannes SixtJan 27, 2012
  32. Junio C HamanoJan 27, 2012
  33. Nguyen Thai Ngoc DuyJan 27, 2012
  34. Jeff KingJan 27, 2012
  35. Ævar Arnfjörð BjarmasonJan 27, 2012
  36. Jeff KingJan 27, 2012

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.