Git development
 help / color / mirror / Atom feed
* Bug with git-config includeIf
@ 2023-04-11 16:05 Matthias Beyer
  2023-04-11 16:58 ` Junio C Hamano
  2023-04-11 17:00 ` Emily Shaffer
  0 siblings, 2 replies; 4+ messages in thread
From: Matthias Beyer @ 2023-04-11 16:05 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

Hi,

please keep me in CC when replying, I am not subscribed.

I experience the following (seemingly) bug in my git setup:

I have three files for my git configuration:

* ~/.gitconfig -> ~/config/git/gitconfig
* ~/config/git/gitconfig_private
* ~/config/git/gitconfig_work

The gitconfig_private sets my email address to this very email address, the 
gitconfig_work sets it to me work email address.

The gitconfig file has a `includeIf` directive:

```
[include]
    path = ~/config/git/gitconfig_private                                                                                                                                                                                                                                                                                    

[includeIf "gitdir:~/dev/work/"]
    path = ~/config/git/gitconfig_work   
```

That means, from my understanding, that all git repositories in ~/dev/work 
should now have the work-related email address set.

If I go to ~/dev/work/somerepo and `git config --get user.email` it indeed 
shows the expected email address.

But if I go to a subdirectory in that repository, the very same command shows 
the private email address, and commits get written with that private email 
address.

Did I miss something obvious or did I discover a bug?

git: 2.38.4

Best,
Matthias

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug with git-config includeIf
  2023-04-11 16:05 Bug with git-config includeIf Matthias Beyer
@ 2023-04-11 16:58 ` Junio C Hamano
  2023-04-12  6:26   ` Matthias Beyer
  2023-04-11 17:00 ` Emily Shaffer
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2023-04-11 16:58 UTC (permalink / raw)
  To: Matthias Beyer; +Cc: git

Matthias Beyer <mail@beyermatthias.de> writes:

> [includeIf "gitdir:~/dev/work/"]
>     path = ~/config/git/gitconfig_work   
> ```
>
> That means, from my understanding, that all git repositories in ~/dev/work 
> should now have the work-related email address set.
>
> If I go to ~/dev/work/somerepo and `git config --get user.email` it indeed 
> shows the expected email address.

The pattern given to "gitdir:" ends with "/" and implicitly "**" is
added after it.  If "~/dev/work/somerepo" is a repository, going
there and "git rev-parse --git-dir" would say ".git" or
"~/dev/work/somerepo/.git", then the includeIf should trigger.

> But if I go to a subdirectory in that repository, the very same command shows 
> the private email address, and commits get written with that private email 
> address.

I use exactly the same configuration (not for working on this
project, though), and your symptom does not reproduce for me, which
puzzles me.  I go to an equivelent of your ~/dev/work/somerepo/subdir
and "git rev-parse --git-dir" would still report an equivalent of
your "~/dev/work/somerepo/.git", and my "git config --show-origin user.name"
does point at the value of "includeIf.gitdir:~/dev/work/.path".

I wonder what the difference of the set-up is.  

My ~/dev/work/somerepo/.git equivalent is a directory.  Perhas yours
is not?  That should not cause any difference and it is merely a
guess in the dark.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug with git-config includeIf
  2023-04-11 16:05 Bug with git-config includeIf Matthias Beyer
  2023-04-11 16:58 ` Junio C Hamano
@ 2023-04-11 17:00 ` Emily Shaffer
  1 sibling, 0 replies; 4+ messages in thread
From: Emily Shaffer @ 2023-04-11 17:00 UTC (permalink / raw)
  To: Matthias Beyer; +Cc: git

On Tue, Apr 11, 2023 at 9:32 AM Matthias Beyer <mail@beyermatthias.de> wrote:
>
> Hi,
>
> please keep me in CC when replying, I am not subscribed.
>
> I experience the following (seemingly) bug in my git setup:
>
> I have three files for my git configuration:
>
> * ~/.gitconfig -> ~/config/git/gitconfig
> * ~/config/git/gitconfig_private
> * ~/config/git/gitconfig_work
>
> The gitconfig_private sets my email address to this very email address, the
> gitconfig_work sets it to me work email address.
>
> The gitconfig file has a `includeIf` directive:
>
> ```
> [include]
>     path = ~/config/git/gitconfig_private
>
> [includeIf "gitdir:~/dev/work/"]
>     path = ~/config/git/gitconfig_work
> ```
>
> That means, from my understanding, that all git repositories in ~/dev/work
> should now have the work-related email address set.
>
> If I go to ~/dev/work/somerepo and `git config --get user.email` it indeed
> shows the expected email address.
>
> But if I go to a subdirectory in that repository, the very same command shows
> the private email address, and commits get written with that private email
> address.

One thing that can help a lot to debug is to run `git config --list
--show-scope` from this subdirectory where your config is misbehaving
- that will help you understand which of _private or _work is being
included in the parse, in which order. It could be there is another
stray config overwriting here.

>
> Did I miss something obvious or did I discover a bug?
>
> git: 2.38.4
>
> Best,
> Matthias

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug with git-config includeIf
  2023-04-11 16:58 ` Junio C Hamano
@ 2023-04-12  6:26   ` Matthias Beyer
  0 siblings, 0 replies; 4+ messages in thread
From: Matthias Beyer @ 2023-04-12  6:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1937 bytes --]

Hi,

thanks for your reply.

I found the issue. As always, one nastly little detail: ~/dev is actually a 
symlink on my system(s) to ~/archive/development/

git rev-parse --git-dir of course resolves that symlink and thus ~/dev/work/ 
does not actually match ~/archive/development/

Using that path in the includeIf produces the expected results. 

Thanks for your patience.
Matthias

Am Dienstag, 11. April 2023, 18:58:08 CEST schrieb Junio C Hamano:
> Matthias Beyer <mail@beyermatthias.de> writes:
> > [includeIf "gitdir:~/dev/work/"]
> > 
> >     path = ~/config/git/gitconfig_work
> > 
> > ```
> > 
> > That means, from my understanding, that all git repositories in ~/dev/work
> > should now have the work-related email address set.
> > 
> > If I go to ~/dev/work/somerepo and `git config --get user.email` it indeed
> > shows the expected email address.
> 
> The pattern given to "gitdir:" ends with "/" and implicitly "**" is
> added after it.  If "~/dev/work/somerepo" is a repository, going
> there and "git rev-parse --git-dir" would say ".git" or
> "~/dev/work/somerepo/.git", then the includeIf should trigger.
> 
> > But if I go to a subdirectory in that repository, the very same command
> > shows the private email address, and commits get written with that
> > private email address.
> 
> I use exactly the same configuration (not for working on this
> project, though), and your symptom does not reproduce for me, which
> puzzles me.  I go to an equivelent of your ~/dev/work/somerepo/subdir
> and "git rev-parse --git-dir" would still report an equivalent of
> your "~/dev/work/somerepo/.git", and my "git config --show-origin user.name"
> does point at the value of "includeIf.gitdir:~/dev/work/.path".
> 
> I wonder what the difference of the set-up is.
> 
> My ~/dev/work/somerepo/.git equivalent is a directory.  Perhas yours
> is not?  That should not cause any difference and it is merely a
> guess in the dark.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-12  6:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-11 16:05 Bug with git-config includeIf Matthias Beyer
2023-04-11 16:58 ` Junio C Hamano
2023-04-12  6:26   ` Matthias Beyer
2023-04-11 17:00 ` Emily Shaffer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox