Skip to content

includeIf'd git configs are ignored when checking for existing credential.username config #2328

Description

@Arnavion

This is the same as #1581 , which OP closed because they claimed they could not repro it, but it definitely repros.

The issue is that gcm calls git config --global and git config --local to look for the credential.username config, both of which do not expand includeIf'd files.

(All of these commands run in the repository directory.)

$ git --version

git version 2.53.0

$ ~/.local/lib/git-credential-manager/git-credential-manager --version

2.7.3+5fa7116896c82164996a609accd1c5ad90fe730a

$ cat ~/.config/git/config

...
[includeIf "hasconfig:remote.*.url:https://dev.azure.com/**"]
	path = ~/.config/git/config-ado

$ cat ~/.config/git/config-ado   # Contains exactly what gcm tries to add to ~/.config/git/config because it think it's not set

...
[credential "azrepos:org/msazure"]
	username = foo@example.com

$ strace -fe execve -s 99 -- git pull --all --prune |& grep 'git.*config.*credential'

...
[pid 754151] execve("/usr/libexec/git/git", ["/usr/libexec/git/git", "config", "--null", "--local", "credential.azrepos:org/msazure.username"], 0x7f6e040cf250 /* 93 vars */) = 0
[pid 754152] execve("/usr/libexec/git/git", ["/usr/libexec/git/git", "config", "--null", "--global", "credential.azrepos:org/msazure.username"], 0x7f6e040cf250 /* 93 vars */) = 0
...

^C

$ git config --local 'credential.azrepos:org/msazure.username'   # With --local as gcm calls it, returns nothing

$ git config --global 'credential.azrepos:org/msazure.username'   # With --global as gcm calls it, returns nothing

$ git config 'credential.azrepos:org/msazure.username'   # Without --local or --global, returns value from includeIf'd config

foo@example.com

$ git config --global --list   # The reason is that config --global just returns the `includeIf` directives as-is instead of expanding them.

...
includeif.hasconfig:remote.*.url:https://dev.azure.com/**.path=~/.config/git/config-ado

$ git config --list   # ... whereas without --global it does expand them.

...
includeif.hasconfig:remote.*.url:https://dev.azure.com/**.path=~/.config/git/config-ado
...
credential.azrepos:org/msazure.username=foo@example.com
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions