threads / discuss / 39168

Fwd: Can't override username of default credential context to have different username in custom context.

Subject: Fwd: Can't override username of default credential context to have different username in custom context.

## tl;dr

3 messages between Apr 27, 2015 and Apr 28, 2015.

replies: 2people: 2as markdown or json

Vladislav Kostenko· Apr 27, 2015, 16:19 UTC · lore
Hi,
Here is my scenario:
1. First I set default username
git config --global credential.username myUsername
2. Then I want to have different username for my other repository
git config --global
credential.https://myOtherRepository.visualstudio.com.username
myOtherUsername
3. When I try to pull new changes, git asks for password of myUsername
Password for 'https://myUsername@myOtherRepository.visualstudio.com':

But I want to have: Password for 'https://myOtherUsername@myOtherRepository.visualstudio.com':

Is there any way to accomplish overriding?
PS: I've found that if I change steps 1 and 2 I will get what I want.
But this is not a solution as it require to unset and set
credential.username after I add a new credential context. So the
ordering does matter and it looks for me like it shouldn't.
-- 
Best regards, Vlad.
Jeff King· Apr 28, 2015, 05:25 UTC · re: Vladislav Kostenko · lore

Re: Fwd: Can't override username of default credential context to have different username in custom context.

On Mon, Apr 27, 2015 at 09:19:31PM +0500, Vladislav Kostenko wrote:
Show 17 quoted lines
> Here is my scenario:
> 
> 1. First I set default username
> git config --global credential.username myUsername
> 
> 2. Then I want to have different username for my other repository
> git config --global
> credential.https://myOtherRepository.visualstudio.com.username
> myOtherUsername
> 
> 3. When I try to pull new changes, git asks for password of myUsername
> Password for 'https://myUsername@myOtherRepository.visualstudio.com':
> 
> But I want to have:
> Password for 'https://myOtherUsername@myOtherRepository.visualstudio.com':
> 
> Is there any way to accomplish overriding?
Only by changing the ordering in the config file, as you noticed.

The other http.* options will choose the most-specific match, but the credential code predates that, and blindly goes in config order. Kyle (cc'd) added the urlmatch support for http.*, and might be able to say whether it could be adapted for the credential code. If so, then I think it would need somebody to volunteer to work on it.

That would technically be a backwards-incompatible change to switch the lookup order at this point in time, but I'm somewhat of the opinion that in any case it matters, the new behavior would be a strict improvement.

-Peff
Jeff King· Apr 28, 2015, 05:25 UTC · re: Jeff King · lore

Re: Fwd: Can't override username of default credential context to have different username in custom context.

[+cc Kyle, who I forgot on the initial send. Oops!]
On Tue, Apr 28, 2015 at 01:25:02AM -0400, Jeff King wrote:
Show 37 quoted lines
> On Mon, Apr 27, 2015 at 09:19:31PM +0500, Vladislav Kostenko wrote:
> 
> > Here is my scenario:
> > 
> > 1. First I set default username
> > git config --global credential.username myUsername
> > 
> > 2. Then I want to have different username for my other repository
> > git config --global
> > credential.https://myOtherRepository.visualstudio.com.username
> > myOtherUsername
> > 
> > 3. When I try to pull new changes, git asks for password of myUsername
> > Password for 'https://myUsername@myOtherRepository.visualstudio.com':
> > 
> > But I want to have:
> > Password for 'https://myOtherUsername@myOtherRepository.visualstudio.com':
> > 
> > Is there any way to accomplish overriding?
> 
> Only by changing the ordering in the config file, as you noticed.
> 
> The other http.* options will choose the most-specific match, but the
> credential code predates that, and blindly goes in config order. Kyle
> (cc'd) added the urlmatch support for http.*, and might be able to say
> whether it could be adapted for the credential code. If so, then I think
> it would need somebody to volunteer to work on it.
> 
> That would technically be a backwards-incompatible change to switch the
> lookup order at this point in time, but I'm somewhat of the opinion that
> in any case it matters, the new behavior would be a strict improvement.
> 
> -Peff
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

← back to recent threads