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

Re: Possible bug in includeIf / conditional includes

From
Raphael Stolt <raphael.stolt@gmail.com>
Date
May 10, 2017, 21:37 UTC
Message-ID
<C2EAA2DF-B7F4-4011-BB0F-4F3BA9E96890@gmail.com>
In-Reply-To
<CC77A0CE-88A5-4A3C-97AF-ED0180FE385B@gmail.com>
Show 45 quoted lines
> Am 10.05.2017 um 23:21 schrieb Raphael Stolt <raphael.stolt@gmail.com>:
> 
>> 
>> Am 10.05.2017 um 21:48 schrieb Ævar Arnfjörð Bjarmason <avarab@gmail.com>:
>> 
>> On Wed, May 10, 2017 at 8:58 PM, Sebastian Schuberth
>> <sschuberth@gmail.com> wrote:
>>> On 2017-05-10 19:00, raphael.stolt@gmail.com wrote:
>>> 
>>>> Current configuration which finds the conditional configuration.
>>>> 
> 
> a)
> 
>>>> ~/.gitconfig
>>>> [includeIf "gitdir:~/Work/git-repos/oss/"]
>>>>  path = ~/Work/git-repos/oss/.oss-gitconfig
>>>> 
>>>> Expected configuration which doesn't find the conditional configuration:
>>>> 
> 
> b)
> 
>>>> ~/.gitconfig
>>>> [includeIf "gitdir:~/Work/git-repos/oss/"]
>>>>  path = .oss-gitconfig
>>> 
>>> 
>>> My guess is, because includeIf might contain other conditionals than
>>> "gitdir", the generic convention is to always use an absolute path for
>>> "path".
>> 
>> [CC'd OP Raphael Stolt, please reply-all]
>> 
>> In both cases the conditional is the same, but the path is relative
>> v.s. absolute.
>> 
>> Raphael: Does the config get included if you cd to
>> ~/Work/git-repos/oss/? From git-config(1):
> 
> Given I’m in a repo in ~/Work/git-repos/oss/ e.g. ~/Work/git-repos/oss/project-repo-a and I’m using config a) 
> the config is used from ~/Work/git-repos/oss/.oss-gitconfig
> 
> Given I’m in a repo in ~/Work/git-repos/oss/ e.g. ~/Work/git-repos/oss/project-repo-a and I’m using config b) 
> the global config is used because there is no .oss-gitconfig in $HOME.

Given I’m in ~/Work/git-repos/oss and I’m using config b) also the global config (~/.gitconfig) is used.

Show 21 quoted lines
> 
> I guess it’s an intended behavior since conditional configuration files __SHOULD__ reside in $HOME rather than 
> in my case in ~/Work/git-repos/oss.
> 
>> 
>> ---cut---
>> The included file is expanded immediately, as if its contents had been
>> found at the location of the include directive. If the value of the
>> `include.path` variable is a relative path, the path is considered to
>> be relative to the configuration file in which the include directive
>> was found.  See below for examples.
>> ---cut---
>> 
>> The commit that added IncludeIf (3efd0bedc6) does something with
>> relative path (just skimming, need to get to other things), but unlike
>> [Include] the docs don't explicitly mention what it's supposed to do
>> with that, and all the examples show absolute paths.
>> 
>> So whether this is a bug in the code or not it seems to definitely be
>> a doc bug, whatever it does with relative files should be in the docs.
> + 1
Previous: Raphael StoltNext: Jeff King
Message 5 of 22 in “Possible bug in includeIf / conditional includes”
  1. raphael.stolt@gmail.comMay 10, 2017
  2. Sebastian SchuberthMay 10, 2017
  3. Ævar Arnfjörð BjarmasonMay 10, 2017
  4. Raphael StoltMay 10, 2017
  5. Raphael StoltMay 10, 2017
  6. Jeff KingMay 11, 2017
  7. Jeff KingMay 11, 2017
  8. Ævar Arnfjörð BjarmasonMay 11, 2017
  9. Jeff KingMay 11, 2017
  10. Ævar Arnfjörð BjarmasonMay 11, 2017
  11. Jeff KingMay 11, 2017
  12. 0/4 doc improvements for config includesJeff King, May 11, 2017
  13. 1/4 docs/config: clarify include/includeIf relationshipJeff King, May 11, 2017
  14. Ramsay JonesMay 11, 2017
  15. Jeff KingMay 12, 2017
  16. 2/4 docs/config: give a relative includeIf exampleJeff King, May 11, 2017
  17. 3/4 docs/config: avoid the term "expand" for includesJeff King, May 11, 2017
  18. 4/4 docs/config: consistify include.path examplesJeff King, May 11, 2017
  19. Junio C HamanoMay 11, 2017
  20. Ævar Arnfjörð BjarmasonMay 11, 2017
  21. Junio C HamanoMay 11, 2017
  22. Jeff KingMay 11, 2017

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.