# Git Conditional Includes Question (possible bug?)

3 messages from 2021-01-29 to 2021-01-31. Participants: Colton Hurst, Junio C Hamano.
Thread: https://gitlist.dev/t/55073

## Colton Hurst, 2021-01-29 21:21

Subject: Git Conditional Includes Question (possible bug?)
Message-ID: <1E4AB5E8-DD46-45CA-9A3F-C49F115BE0D4@coltonhurst.com>
URL: https://gitlist.dev/e/1E4AB5E8-DD46-45CA-9A3F-C49F115BE0D4%40coltonhurst.com

```
Hello,

I am attempting to use Git conditional includes, but it does not seem to work for me. Can you please help me find out what I’m doing wrong?

[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.

Is this correct behavior? It seems like Git is not recognizing my `.gitconfig` file, and the configuration is not set correctly.

I’m using git version 2.30.0 with on a Mac version 11.1 (Big Sur)
My main shell is: fish, version 3.1.2
I also have tested & have the same issues using: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)

To reproduce, I have the two files at the listed locations:

`.gitconfig` at: `~/`, with the following contents:

[user]
	name = Colton Hurst

[includeIf "gitdir:~/colton/github"]
	path = ~/colton/github/.gitconfig

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

`.gitconfig` at: `~/colton/github`, with the following contents:

[user]
	name = Colton Hurst
	email = colton@coltonhurst.com

This is the output from `git bugreport`:

[System Info]
git version:
git version 2.30.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Darwin 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec  2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64
compiler info: clang: 12.0.0 (clang-1200.0.32.28)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh


Thank you for reading,


cdh


```

## Junio C Hamano, 2021-01-29 22:54

Subject: Re: Git Conditional Includes Question (possible bug?)
Message-ID: <xmqqlfcbs69z.fsf@gitster.c.googlers.com>
URL: https://gitlist.dev/e/xmqqlfcbs69z.fsf%40gitster.c.googlers.com
In-Reply-To: <1E4AB5E8-DD46-45CA-9A3F-C49F115BE0D4@coltonhurst.com>

```
Colton Hurst <colton@coltonhurst.com> 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.


```

## Colton Hurst, 2021-01-31 04:23

Subject: Re: Git Conditional Includes Question (possible bug?)
Message-ID: <B569AC8C-8AF3-46E6-B8FB-A6EBEF42FA00@coltonhurst.com>
URL: https://gitlist.dev/e/B569AC8C-8AF3-46E6-B8FB-A6EBEF42FA00%40coltonhurst.com
In-Reply-To: <xmqqlfcbs69z.fsf@gitster.c.googlers.com>

```
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
```
