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

Re: Bug with git-config includeIf

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 11, 2023, 16:58 UTC
Message-ID
<xmqqr0sq9x0f.fsf@gitster.g>
In-Reply-To
<3352350.44csPzL39Z@takeshi>
Matthias Beyer <mail@beyermatthias.de> writes:
Show 9 quoted lines
> [includeIf "gitdir:~/dev/work/"]
>     path = ~/config/git/gitconfig_work   
> ```
>
> That means, from my understanding, that all git repositories in ~/dev/work 
> should now have the work-related email address set.
>
> If I go to ~/dev/work/somerepo and `git config --get user.email` it indeed 
> shows the expected email address.

The pattern given to "gitdir:" ends with "/" and implicitly "**" is added after it. If "~/dev/work/somerepo" is a repository, going there and "git rev-parse --git-dir" would say ".git" or "~/dev/work/somerepo/.git", then the includeIf should trigger.

> But if I go to a subdirectory in that repository, the very same command shows 
> the private email address, and commits get written with that private email 
> address.

I use exactly the same configuration (not for working on this project, though), and your symptom does not reproduce for me, which puzzles me. I go to an equivelent of your ~/dev/work/somerepo/subdir and "git rev-parse --git-dir" would still report an equivalent of your "~/dev/work/somerepo/.git", and my "git config --show-origin user.name" does point at the value of "includeIf.gitdir:~/dev/work/.path".

I wonder what the difference of the set-up is.  

My ~/dev/work/somerepo/.git equivalent is a directory. Perhas yours is not? That should not cause any difference and it is merely a guess in the dark.

Previous: Matthias BeyerNext: Matthias Beyer
Message 2 of 4 in “Bug with git-config includeIf”
  1. Matthias BeyerApr 11, 2023
  2. Junio C HamanoApr 11, 2023
  3. Matthias BeyerApr 12, 2023
  4. Emily ShafferApr 11, 2023

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.