# includeIf appears to not be working

5 messages from 2022-12-12 to 2022-12-12. Participants: Joshua J. Kugler, Eric Sunshine, Jeff King.
Thread: https://gitlist.dev/t/58938

## Joshua J. Kugler, 2022-12-12 20:19

Subject: includeIf appears to not be working
Message-ID: <8316344.DvuYhMxLoT@hosanna>
URL: https://gitlist.dev/e/8316344.DvuYhMxLoT%40hosanna

```
So, I've set up includeIf before, and have had it working, but it seems to not 
be working in my latest attempt.

This is git 2.38.2 on Ubuntu Linux 20.04.

Contents of ~/.gitconfig (truncated):

[user]
        name = Joshua Kugler
        email = joshua@personal.com
[includIf "gitdir:~/repos/work/"]
        path = ~/repos/work/gitconfig

Contents of ~/repos/work/gitconfig:

[user]
        name = Joshua Kugler
        email = joshua@work.io

Now, if I do this:

cd /home/jkugler/repos/work/some_repo

and run:

$ git config --show-origin --get user.email
file:/home/jkugler/.gitconfig   joshua@personal.com

Like I said, I've set this up before, and had it working. I don't know what 
I'm doing differently/wrong...but would be happy to be told so.

Is there a debug command which can show if the gitdir is/isn't matching like I 
thought it should?  What other command output could help debug this?

Thanks!

j

-- 
Joshua J. Kugler - Fairbanks, Alaska - joshua@azariah.com
Azariah Enterprises - Programming and Website Design
PGP Key: http://pgp.mit.edu/  ID 0x68108cbb73b13b6a



```

## Eric Sunshine, 2022-12-12 20:54

Subject: Re: includeIf appears to not be working
Message-ID: <CAPig+cRv02F2yw3Ej1_7PKUV5stKcff82GtdUe5X3wnPfDhfmw@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcRv02F2yw3Ej1_7PKUV5stKcff82GtdUe5X3wnPfDhfmw%40mail.gmail.com
In-Reply-To: <8316344.DvuYhMxLoT@hosanna>

```
On Mon, Dec 12, 2022 at 3:36 PM Joshua J. Kugler <joshua@azariah.com> wrote:
> So, I've set up includeIf before, and have had it working, but it seems to not
> be working in my latest attempt.
>
> Contents of ~/.gitconfig (truncated):
>
> [user]
>         name = Joshua Kugler
>         email = joshua@personal.com
> [includIf "gitdir:~/repos/work/"]

Missing "e" in "includeIf".

```

## Jeff King, 2022-12-12 20:55

Subject: Re: includeIf appears to not be working
Message-ID: <Y5eVTrK2CO0h5BPl@coredump.intra.peff.net>
URL: https://gitlist.dev/e/Y5eVTrK2CO0h5BPl%40coredump.intra.peff.net
In-Reply-To: <8316344.DvuYhMxLoT@hosanna>

```
On Mon, Dec 12, 2022 at 11:19:41AM -0900, Joshua J. Kugler wrote:

> Contents of ~/.gitconfig (truncated):
> 
> [user]
>         name = Joshua Kugler
>         email = joshua@personal.com
> [includIf "gitdir:~/repos/work/"]
>         path = ~/repos/work/gitconfig

Maybe a dumb question, but is this cut-and-paste verbatim? If so, then
perhaps s/includ/include/ would help?

With that change, your example works for me.

> Like I said, I've set this up before, and had it working. I don't know what 
> I'm doing differently/wrong...but would be happy to be told so.

If it's not the typo, then possibly there are symlinks involved? We'll
run realpath() on the repository directory before matching, so your
pattern needs to take that into account.

> Is there a debug command which can show if the gitdir is/isn't
> matching like I thought it should?  What other command output could
> help debug this?

No, there's no debug/tracing code for this feature. You'd have to run it
under gdb (break on the include_by_gitdir function).

-Peff

```

## Jeff King, 2022-12-12 20:57

Subject: Re: includeIf appears to not be working
Message-ID: <Y5eVsb8rIH9TFgIj@coredump.intra.peff.net>
URL: https://gitlist.dev/e/Y5eVsb8rIH9TFgIj%40coredump.intra.peff.net
In-Reply-To: <Y5eVTrK2CO0h5BPl@coredump.intra.peff.net>

```
On Mon, Dec 12, 2022 at 03:55:42PM -0500, Jeff King wrote:

> > Is there a debug command which can show if the gitdir is/isn't
> > matching like I thought it should?  What other command output could
> > help debug this?
> 
> No, there's no debug/tracing code for this feature. You'd have to run it
> under gdb (break on the include_by_gitdir function).

Oh, one other command you could try:

  git rev-parse --absolute-git-dir

while in the repository in question. I think that would do the same
normalization of the path (including resolving symlinks). So that would
tell you what Git should be matching against.

-Peff

```

## Joshua J. Kugler, 2022-12-12 21:05

Subject: Re: includeIf appears to not be working
Message-ID: <5349174.mvXUDI8C0e@hosanna>
URL: https://gitlist.dev/e/5349174.mvXUDI8C0e%40hosanna
In-Reply-To: <CAPig+cRv02F2yw3Ej1_7PKUV5stKcff82GtdUe5X3wnPfDhfmw@mail.gmail.com>

```
All -

Yep, that was copy/paste verbatim, and yep, that was the issue.

Thank you to all who spotted the missing "e".  Siiiiigh. I looked at that so 
many times, and didn't even see it.

Sorry to waste your time, and I much appreciate the quick response!

j

On Monday, December 12, 2022 11:54:48 AM AKST Eric Sunshine wrote:
> On Mon, Dec 12, 2022 at 3:36 PM Joshua J. Kugler <joshua@azariah.com> wrote:
> > So, I've set up includeIf before, and have had it working, but it seems to
> > not be working in my latest attempt.
> > 
> > Contents of ~/.gitconfig (truncated):
> > 
> > [user]
> > 
> >         name = Joshua Kugler
> >         email = joshua@personal.com
> > 
> > [includIf "gitdir:~/repos/work/"]
> 
> Missing "e" in "includeIf".


-- 
Joshua J. Kugler - Fairbanks, Alaska - joshua@azariah.com
Azariah Enterprises - Programming and Website Design
PGP Key: http://pgp.mit.edu/  ID 0x68108cbb73b13b6a



```
