Re: Git Conditional Includes Question (possible bug?)
From: Junio C Hamano <hidden>
Date: 2021-01-29 22:55:34
Colton Hurst [off-list ref] writes:
[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.