Re: Git Conditional Includes Question (possible bug?)

2 messages, 2 authors, 2021-01-31 · open the first message on its own page

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.

Re: Git Conditional Includes Question (possible bug?)

From: Colton Hurst <hidden>
Date: 2021-01-31 04:36:38

Junio,
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.
That solved the issue. My email was in the subdirectory config files, but not having the `/` at the end of the path ruined it. Thank you so much for the help!

Have a great day and weekend!


Colton
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help