Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

credential.namespace setting ignored when coming from conditionally included config file #912

Open
2 of 6 tasks
conioh opened this issue Sep 7, 2020 · 0 comments
Open
2 of 6 tasks

Comments

@conioh
Copy link

conioh commented Sep 7, 2020

Which Version of GCM are you using ?

1.20.0

Which service are you trying to connect to

  • Azure DevOps
  • Azure DevOps Server (TFS/on-prem)
  • GitHub
  • GitHub Enterprise
  • Bitbucket
  • Other? - please describe;

Expected behavior

I'm using conditional includes in my ~/.gitconfig file to have different settings depending on their path. This works for most settings, but not for credential.namespace.

If I put:

[credential]
    namespace = foo

in my ~/.gitconfig file and login, I see in the Windows Credential Manager (the Control Panel applet) credentials for foo:http://github.com:
image

I expect the same to happens if I put those two line in a separate file and include it in my ~/.gitconfig file.

Actual behavior

If I put the same two lines in a different file and include it in my ~/.gitconfig file and conditionally include it GCM tries to re-authenticate, and once I enter my credentials again we see that it additionally creates git:https://github.com:
image

Set the env variables GCM_TRACE=1 and GIT_TRACE=1 and run your git command. Redact any private information and attach the log

conio@ME-T490:master:/d/Pers/Code/shell32_git_crash> git config --get credential.namespace
foo
conio@ME-T490:master:/d/Pers/Code/shell32_git_crash> GCM_TRACE=1 GIT_TRACE=1 git push --dry-run
01:01:19.917780 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
01:01:19.920535 git.c:444               trace: built-in: git push --dry-run
01:01:19.921579 run-command.c:663       trace: run_command: GIT_DIR=.git git remote-https origin https://github.com/conioh/shell32_git_crash.git
01:01:19.941316 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
01:01:19.943849 git.c:704               trace: exec: git-remote-https origin https://github.com/conioh/shell32_git_crash.git
01:01:19.943849 run-command.c:663       trace: run_command: git-remote-https origin https://github.com/conioh/shell32_git_crash.git
01:01:19.965396 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
01:01:20.611738 run-command.c:663       trace: run_command: 'git credential-manager get'
01:01:20.668368 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
01:01:20.669339 git.c:704               trace: exec: git-credential-manager get
01:01:20.669339 run-command.c:663       trace: run_command: git-credential-manager get
01:01:20.725975 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.20.0) 'get'
01:01:20.769415 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
01:01:20.786350 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
01:01:20.828667 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'https://github.com/'.
01:01:20.838252 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://github.com/'.
01:01:20.845591 ...\Common.cs:176       trace: [CreateAuthentication] authority for 'https://github.com/' is GitHub.
01:01:20.845591 ...\Common.cs:765       trace: [QueryCredentials] querying 'GitHub' for credentials.
01:01:20.872037 ...icationPrompts.cs:50 trace: [CredentialModalPrompt] prompting user for credentials for 'https://github.com/'.
01:01:27.257680 ...\Authority.cs:101    trace: [AcquireToken] server responded with Unauthorized.
01:01:27.263676 ...\Authority.cs:139    trace: [AcquireToken] two-factor app authentication code required for 'https://github.com/'.
01:01:27.267135 ...icationPrompts.cs:64 trace: [AuthenticationCodeModalPrompt] prompting user for authentication code for 'https://github.com/'.
01:01:31.679339 ...\Authority.cs:101    trace: [AcquireToken] server responded with Created.
01:01:31.682091 ...\Authority.cs:125    trace: [AcquireToken] authentication success: new personal access token for 'https://github.com/' created.
01:01:31.683149 ...uthentication.cs:219 trace: [InteractiveLogon] token acquisition for 'https://github.com/' succeeded.
01:01:32.573685 ...\Authority.cs:200    trace: [ValidateCredentials] credential validation for 'https://github.com/' succeeded.
01:01:32.574366 ...\Common.cs:873       trace: [QueryCredentials] credentials for 'https://github.com/' found.
01:01:32.575266 ...\Common.cs:709       trace: [LogEvent] GitHub credentials for 'https://github.com/' successfully retrieved.
01:01:33.736273 run-command.c:663       trace: run_command: 'git credential-manager store'
01:01:33.839574 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
01:01:33.843216 git.c:704               trace: exec: git-credential-manager store
01:01:33.843216 run-command.c:663       trace: run_command: git-credential-manager store
01:01:33.931191 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.20.0) 'store'
01:01:33.982690 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
01:01:33.996293 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
01:01:34.025263 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'https://PersonalAccessToken@github.com/'.
01:01:34.036989 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://PersonalAccessToken@github.com/'.
01:01:34.044500 ...\Common.cs:176       trace: [CreateAuthentication] authority for 'https://PersonalAccessToken@github.com/' is GitHub.
01:01:34.044500 ...\Program.cs:526      trace: [Store] storing GitHub credentials for 'https://PersonalAccessToken@github.com/'.
Everything up-to-date

The part that is missing is the middle line in the following snippet:

...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
...\Common.cs:588       trace: [LoadOperationArguments] namespace = 'foo'.
...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'https://github.com/'.

That's what happens when I put the configuration directly in the ~/.gitconfig file or include it unconditionally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant