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

Re: Git Conditional Includes Question (possible bug?)

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 29, 2021, 22:54 UTC
Message-ID
<xmqqlfcbs69z.fsf@gitster.c.googlers.com>
In-Reply-To
<1E4AB5E8-DD46-45CA-9A3F-C49F115BE0D4@coltonhurst.com>
Colton Hurst <colton@coltonhurst.com> writes:
Show 7 quoted lines
> [Expectation] When I run `cd ~/colton/github/coltonhurst.com`
> (this is a valid git repo) and then run `git config user.email`, I
> expect ‘colton@coltonhurst.com’ will be returned.
>
> [Actual Result] When I run `cd ~/colton/github/coltonhurst.com`
> (this is a valid git repo) and then run `git config user.email`,
> nothing is returned.
The relevant part of the per-user config are
> [user]
> 	name = Colton Hurst
This is not conditional, and applies when you are in the repository.
> [includeIf "gitdir:~/colton/github"]
> 	path = ~/colton/github/.gitconfig

This is conditional, and applies when you are in a repository whose ".git" location matches the glob pattern "~/colton/github". The location in question is "~/colton/github/coltonhurst.com", which does not match the pattern, so it would be skipped.

> [includeIf "gitdir:~/colton/sourcehut"]
> 	path = ~/colton/sourcehut/.gitconfig
Likewise.

So, nobody sets user.email in your example. Isn't it expected that nothing is returned?

I wonder what happens when the second one is updated to
> [includeIf "gitdir:~/colton/github/"]
> 	path = ~/colton/github/.gitconfig
as "git config --help" says:
 * If the pattern ends with `/`, `**` will be automatically added. For
   example, the pattern `foo/` becomes `foo/**`. In other words, it
   matches "foo" and everything inside, recursively.

and "~/colton/github/**" as a pattern would match the path to the repository in question.

Previous: Colton HurstNext: Colton Hurst
Message 2 of 3 in “Git Conditional Includes Question (possible bug?)”
  1. Colton HurstJan 29, 2021
  2. Junio C HamanoJan 29, 2021
  3. Colton HurstJan 31, 2021

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.