git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [RFE] Please add name and email to git credentials
@ 2018-11-01  9:59 Nicolas Mailhot
  2018-11-01 11:22 ` Ævar Arnfjörð Bjarmason
  2018-11-01 11:32 ` Nicolas Mailhot
  0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Mailhot @ 2018-11-01  9:59 UTC (permalink / raw)
  To: git

Hi,

A dev persona is not just a username, please add email (and probably
also name) support to git credentials so the correct set for a repo url
is automatically picked up by git

Regards,

-- 
Nicolas Mailhot


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

* Re: [RFE] Please add name and email to git credentials
  2018-11-01  9:59 [RFE] Please add name and email to git credentials Nicolas Mailhot
@ 2018-11-01 11:22 ` Ævar Arnfjörð Bjarmason
  2018-11-01 12:34   ` Nicolas Mailhot
  2018-11-01 11:32 ` Nicolas Mailhot
  1 sibling, 1 reply; 13+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-11-01 11:22 UTC (permalink / raw)
  To: Nicolas Mailhot; +Cc: git


On Thu, Nov 01 2018, Nicolas Mailhot wrote:

> A dev persona is not just a username, please add email (and probably
> also name) support to git credentials so the correct set for a repo url
> is automatically picked up by git

The "git-credential" helper needs to look at a URL like
git@github.com:git/git.git and decide that protocol=ssh, username=git,
host=github.com, path=git/git.git etc, because that's the credential we
need to lookup to push to.

Where would we get an E-Mail to lookup to pass to the helper? Are you
just asking that the helper git the result of $(git config user.name &&
git config user.email)? If so why can't it just look this up itself?

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

* Re: [RFE] Please add name and email to git credentials
  2018-11-01  9:59 [RFE] Please add name and email to git credentials Nicolas Mailhot
  2018-11-01 11:22 ` Ævar Arnfjörð Bjarmason
@ 2018-11-01 11:32 ` Nicolas Mailhot
  1 sibling, 0 replies; 13+ messages in thread
From: Nicolas Mailhot @ 2018-11-01 11:32 UTC (permalink / raw)
  To: git

Le jeudi 01 novembre 2018 à 10:59 +0100, Nicolas Mailhot a écrit :
> Hi,
> 
> A dev persona is not just a username, please add email (and probably
> also name) support to git credentials so the correct set for a repo
> url
> is automatically picked up by git

So, just in case it was not clear enough, allow things in .gitconfig
like

[credential "https://pkgs.fedoraproject.org/"]
username = doe4ever
name = John Doe
email = foo4ever@fedoraproject.org
[credential "https://gitlab.corp.com/"]
username = jdoe56874
name = John Doe, Snr Engineer
email = john.doe@corp.com

Instead of just

[user]
name = John Doe
email =  john.doe@corp.com
[credential "https://pkgs.fedoraproject.org/"]
username = doe4ever
email = foo@fedoraproject.org
[credential "https://gitlab.corp.com/"]
username = jdoe56874

and drat, I've commited to XXX with the wrong name/email again

-- 
Nicolas Mailhot


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

* Re: [RFE] Please add name and email to git credentials
  2018-11-01 11:22 ` Ævar Arnfjörð Bjarmason
@ 2018-11-01 12:34   ` Nicolas Mailhot
  2018-11-01 13:15     ` Ævar Arnfjörð Bjarmason
  2018-11-01 14:13     ` Christian Couder
  0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Mailhot @ 2018-11-01 12:34 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git

Le jeudi 01 novembre 2018 à 12:22 +0100, Ævar Arnfjörð Bjarmason a
écrit :
> 
> Where would we get an E-Mail to lookup to pass to the helper? Are you
> just asking that the helper git the result of $(git config user.name
> &&
> git config user.email)? If so why can't it just look this up itself?


So, just in case it was not clear enough, allow things in .gitconfig
like

[credential "https://pkgs.fedoraproject.org/"]
username = doe4ever
name = John Doe
email = doe4ever@fedoraproject.org
[credential "https://gitlab.corp.com/"]
username = jdoe56874
name = John Doe, Snr Engineer
email = john.doe@corp.com

Instead of just

[user]
name = John Doe
email =  john.doe@corp.com
[credential "https://pkgs.fedoraproject.org/"]
username = doe4ever
[credential "https://gitlab.corp.com/"]
username = jdoe56874

and drat, I've commited to XXX with the wrong name/email again


-- 
Nicolas Mailhot


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

* Re: [RFE] Please add name and email to git credentials
  2018-11-01 12:34   ` Nicolas Mailhot
@ 2018-11-01 13:15     ` Ævar Arnfjörð Bjarmason
  2018-11-01 14:13     ` Christian Couder
  1 sibling, 0 replies; 13+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-11-01 13:15 UTC (permalink / raw)
  To: Nicolas Mailhot; +Cc: git


On Thu, Nov 01 2018, Nicolas Mailhot wrote:

> Le jeudi 01 novembre 2018 à 12:22 +0100, Ævar Arnfjörð Bjarmason a
> écrit :
>>
>> Where would we get an E-Mail to lookup to pass to the helper? Are you
>> just asking that the helper git the result of $(git config user.name
>> &&
>> git config user.email)? If so why can't it just look this up itself?
>
>
> So, just in case it was not clear enough, allow things in .gitconfig
> like
>
> [credential "https://pkgs.fedoraproject.org/"]
> username = doe4ever
> name = John Doe
> email = doe4ever@fedoraproject.org
> [credential "https://gitlab.corp.com/"]
> username = jdoe56874
> name = John Doe, Snr Engineer
> email = john.doe@corp.com
>
> Instead of just
>
> [user]
> name = John Doe
> email =  john.doe@corp.com
> [credential "https://pkgs.fedoraproject.org/"]
> username = doe4ever
> [credential "https://gitlab.corp.com/"]
> username = jdoe56874
>
> and drat, I've commited to XXX with the wrong name/email again

Aaaah! So really you just want to set user.{name,email} if you match a
given URL in the project, and this per-se has nothing to do with
credentials..

Yeah that's a fair request. Although I think tying that up with
credential.* doesn't make sense because we'd:

 1) Need yet another place (config, env vars, now this...) to search for
    what we're putting in the commit object.

 2) Users want to configure this for e.g. different URLs even though
    they don't need different credentials for the two.

I'm too lazy to dig up the thread, but there's been a discussion before
of extending the IncludeIf syntax to support more things that "gitdir",
e.g. matching on the remote URL.

So then you'd do:

    [credential "https://pkgs.fedoraproject.org/"]
    username = doe4ever
    [IncludeIf "remote:https://pkgs.fedoraproject.org/*"]
    path ~/.gitconfig.d/fedoraproject.config

But now what you need to do is clone all the projects in
e.g. ~/git/fedoraproject/* and do:

    [credential "https://pkgs.fedoraproject.org/"]
    username = doe4ever
    [IncludeIf "gitdir:~/g/fedoraproject/*"]
    path ~/.gitconfig.d/fedoraproject.config

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

* Re: [RFE] Please add name and email to git credentials
  2018-11-01 12:34   ` Nicolas Mailhot
  2018-11-01 13:15     ` Ævar Arnfjörð Bjarmason
@ 2018-11-01 14:13     ` Christian Couder
  2018-11-01 14:32       ` Randall S. Becker
  2018-11-01 14:42       ` Nicolas Mailhot
  1 sibling, 2 replies; 13+ messages in thread
From: Christian Couder @ 2018-11-01 14:13 UTC (permalink / raw)
  To: nicolas.mailhot; +Cc: git

On Thu, Nov 1, 2018 at 2:31 PM Nicolas Mailhot
<nicolas.mailhot@laposte.net> wrote:
>
> Le jeudi 01 novembre 2018 à 12:22 +0100, Ævar Arnfjörð Bjarmason a
> écrit :
> >
> > Where would we get an E-Mail to lookup to pass to the helper? Are you
> > just asking that the helper git the result of $(git config user.name
> > &&
> > git config user.email)? If so why can't it just look this up itself?
>
> So, just in case it was not clear enough, allow things in .gitconfig
> like
>
> [credential "https://pkgs.fedoraproject.org/"]
> username = doe4ever
> name = John Doe
> email = doe4ever@fedoraproject.org
> [credential "https://gitlab.corp.com/"]
> username = jdoe56874
> name = John Doe, Snr Engineer
> email = john.doe@corp.com
>
> Instead of just
>
> [user]
> name = John Doe
> email =  john.doe@corp.com
> [credential "https://pkgs.fedoraproject.org/"]
> username = doe4ever
> [credential "https://gitlab.corp.com/"]
> username = jdoe56874
>
> and drat, I've commited to XXX with the wrong name/email again

How can Git know when you commit where you will want to push the
commit afterwards?

What if you want to push the same commit to 2 different places that
need different credentials?

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

* RE: [RFE] Please add name and email to git credentials
  2018-11-01 14:13     ` Christian Couder
@ 2018-11-01 14:32       ` Randall S. Becker
  2018-11-01 14:42       ` Nicolas Mailhot
  1 sibling, 0 replies; 13+ messages in thread
From: Randall S. Becker @ 2018-11-01 14:32 UTC (permalink / raw)
  To: 'Christian Couder', nicolas.mailhot; +Cc: 'git'

On November 1, 2018 10:13 AM, Christian Couder wrote:
> Sent: > To: nicolas.mailhot@laposte.net
> Cc: git <git@vger.kernel.org>
> Subject: Re: [RFE] Please add name and email to git credentials
> 
> On Thu, Nov 1, 2018 at 2:31 PM Nicolas Mailhot
> <nicolas.mailhot@laposte.net> wrote:
> >
> > Le jeudi 01 novembre 2018 à 12:22 +0100, Ævar Arnfjörð Bjarmason a
> > écrit :
> > >
> > > Where would we get an E-Mail to lookup to pass to the helper? Are
> > > you just asking that the helper git the result of $(git config
> > > user.name && git config user.email)? If so why can't it just look
> > > this up itself?
> >
> > So, just in case it was not clear enough, allow things in .gitconfig
> > like
> >
> > [credential "https://pkgs.fedoraproject.org/"]
> > username = doe4ever
> > name = John Doe
> > email = doe4ever@fedoraproject.org
> > [credential "https://gitlab.corp.com/"] username = jdoe56874 name =
> > John Doe, Snr Engineer email = john.doe@corp.com
> >
> > Instead of just
> >
> > [user]
> > name = John Doe
> > email =  john.doe@corp.com
> > [credential "https://pkgs.fedoraproject.org/"]
> > username = doe4ever
> > [credential "https://gitlab.corp.com/"] username = jdoe56874
> >
> > and drat, I've commited to XXX with the wrong name/email again
> 
> How can Git know when you commit where you will want to push the
> commit afterwards?
> 
> What if you want to push the same commit to 2 different places that need
> different credentials?

Agree. You are asking git to change history depending on where pushes are done. Applying a legacy VCS paradigm here? Git has a global view of history. It must be the same everywhere, so if you push to two different places, the history must be the same, because those two places may in turn push to another shared repo. Then who is the authority?

What I have managed to do is to associated name and email with config --local so that it binds to the clone and overrides your --global setting. I can have different identities based on what clone I am working on, but once history is created, that's it. If I push from one clone to another, the identity of the clone where I did my first commit is what the second clone sees.

Hope this helps.
Randall

-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.




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

* Re: [RFE] Please add name and email to git credentials
  2018-11-01 14:13     ` Christian Couder
  2018-11-01 14:32       ` Randall S. Becker
@ 2018-11-01 14:42       ` Nicolas Mailhot
  2018-11-02  8:27         ` Christian Couder
  1 sibling, 1 reply; 13+ messages in thread
From: Nicolas Mailhot @ 2018-11-01 14:42 UTC (permalink / raw)
  To: Christian Couder; +Cc: git

Le jeudi 01 novembre 2018 à 15:13 +0100, Christian Couder a écrit :
> 
> How can Git know when you commit where you will want to push the
> commit afterwards?

You have an url in the repo config. of course you can change it between
the commit and the push, but that's not the general case.

Nowadays, most git projects have a preferred git hosting, and your
name/email with the project match the credentials you use to push
(otherwise things like gitlab/github issues trackers would not work at
all).

> What if you want to push the same commit to 2 different places that
> need different credentials?

Then you do not use git credentials and have to configure all by hand.
Which will usually be a major error-prone PITA, so you’ll end up pushing
to the system that matches the ID you want to se in git logs, and then
push from this system to others.

-- 
Nicolas Mailhot


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

* Re: [RFE] Please add name and email to git credentials
  2018-11-01 14:42       ` Nicolas Mailhot
@ 2018-11-02  8:27         ` Christian Couder
  2018-11-02  8:57           ` Nicolas Mailhot
  0 siblings, 1 reply; 13+ messages in thread
From: Christian Couder @ 2018-11-02  8:27 UTC (permalink / raw)
  To: nicolas.mailhot; +Cc: git

On Thu, Nov 1, 2018 at 3:42 PM Nicolas Mailhot
<nicolas.mailhot@gmail.com> wrote:
>
> Le jeudi 01 novembre 2018 à 15:13 +0100, Christian Couder a écrit :
> >
> > How can Git know when you commit where you will want to push the
> > commit afterwards?
>
> You have an url in the repo config. of course you can change it between
> the commit and the push, but that's not the general case.

If I did a `git init`, then I have no url in the repo config. Also if
I cloned from a repo that has a different URL than the sites I have
credentials for, then how should git use the URL in the repo config?

> Nowadays, most git projects have a preferred git hosting, and your
> name/email with the project match the credentials you use to push
> (otherwise things like gitlab/github issues trackers would not work at
> all).

I think you are talking about a special need that you have, but it's
not the same for everyone. For example I always use my real name
"Christian Couder", and when my email changes, I would like it to
change everywhere, so support for .mailmap files in GitHub and GitLab
for example would be much more important for me than what you suggest.

> > What if you want to push the same commit to 2 different places that
> > need different credentials?
>
> Then you do not use git credentials and have to configure all by hand.
> Which will usually be a major error-prone PITA, so you’ll end up pushing
> to the system that matches the ID you want to se in git logs, and then
> push from this system to others.

You could have no user.name and user.email configured in your global
config, and a script that configures those in the local config
depending on remote.origin.url. So when you commit in a repo, Git will
fail if user.name and user.email are not already configured in the
repo. It will tell you to configure those, then you just have to run
your script to get those configured locally, and you are good to go.

Another more flexible possibility is what Ævar suggest with
conditional includes in the config.

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

* Re: [RFE] Please add name and email to git credentials
  2018-11-02  8:27         ` Christian Couder
@ 2018-11-02  8:57           ` Nicolas Mailhot
  2018-11-02 16:51             ` Jeff King
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Mailhot @ 2018-11-02  8:57 UTC (permalink / raw)
  To: Christian Couder, nicolas.mailhot; +Cc: git

Le vendredi 02 novembre 2018 à 09:27 +0100, Christian Couder a écrit :
> On Thu, Nov 1, 2018 at 3:42 PM Nicolas Mailhot
> <nicolas.mailhot@gmail.com> wrote:
> > Le jeudi 01 novembre 2018 à 15:13 +0100, Christian Couder a écrit :
> > > How can Git know when you commit where you will want to push the
> > > commit afterwards?
> > 
> > You have an url in the repo config. of course you can change it
> > between
> > the commit and the push, but that's not the general case.
> 
> If I did a `git init`, then I have no url in the repo config. Also if
> I cloned from a repo that has a different URL than the sites I have
> credentials for, then how should git use the URL in the repo config?

Then you have no need or use for git credentials. Where’s the problem? 

Will the fact that git credential users, that already have per-repo-url
settings in their .gitconfig, will also be able to use this existing
per-url section to control the mail and name associated with their
repos, wake you at night, or something?

> You could have no user.name and user.email configured in your global
> config, and a script that configures those in the local config
> depending on remote.origin.url. 

One could use the same arguments to say git credentials is not
necessary, it's a maintenance burden, everyone should just script their
auth needs manually, etc.

Are you arguing for git credentails removal here?

Or are you arguing that having two separate mecanisms in git, to match
config directives to repo urls, is some kind of improvement?

I didn't create or write or specify the way git credential matches repo
urls. It already exists within git. If you have a problem with the
matching logic git credential uses, why are you arguing with me instead
of taking it up with the maintainers of this logic?

Regards,

-- 
Nicolas Mailhot


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

* Re: [RFE] Please add name and email to git credentials
  2018-11-02  8:57           ` Nicolas Mailhot
@ 2018-11-02 16:51             ` Jeff King
  2018-11-02 17:32               ` Nicolas Mailhot
  0 siblings, 1 reply; 13+ messages in thread
From: Jeff King @ 2018-11-02 16:51 UTC (permalink / raw)
  To: Nicolas Mailhot; +Cc: git

On Fri, Nov 02, 2018 at 09:57:30AM +0100, Nicolas Mailhot wrote:

> Or are you arguing that having two separate mecanisms in git, to match
> config directives to repo urls, is some kind of improvement?

There are already are multiple mechanisms (e.g., http.* config). So that
ship has sailed. ;)

> I didn't create or write or specify the way git credential matches repo
> urls. It already exists within git. If you have a problem with the
> matching logic git credential uses, why are you arguing with me instead
> of taking it up with the maintainers of this logic?

I did create the way git credential matches repo urls. And I do not
think your proposal is a good idea. The credential system is about
interacting with a remote URL, and creating a commit object is a local
operation. That mismatch leaks through when you work with multiple
remotes, since it is not clear which URL we would match against when the
operation does not involve a remote at all.

If you want to have per-repo name/email for creating commits, right now
your option is to have conditional config based on the local filesystem
path.

Elsewhere in this thread[1] Ævar suggested having conditional config
directives based on the presence of a remote. I'm a little hesitant
there because it requires the config parsing to depend on the value of
another key (introducing subtle timing dependencies). But aside from
bizarre corner cases (e.g., including config for remote.* via a
conditional include on the remote.* config), I think it would do what
you want and would be generally useful.

That seems like a more fruitful direction to me.

-Peff

[1] https://public-inbox.org/git/87wopxj5wr.fsf@evledraar.gmail.com/

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

* Re: [RFE] Please add name and email to git credentials
  2018-11-02 16:51             ` Jeff King
@ 2018-11-02 17:32               ` Nicolas Mailhot
  2018-11-02 17:56                 ` Jeff King
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Mailhot @ 2018-11-02 17:32 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Le vendredi 02 novembre 2018 à 12:51 -0400, Jeff King a écrit :

Hi,

Thank you for reading the RFE.

> I did create the way git credential matches repo urls. And I do not
> think your proposal is a good idea. The credential system is about
> interacting with a remote URL, and creating a commit object is a local
> operation. That mismatch leaks through when you work with multiple
> remotes, since it is not clear which URL we would match against when
> the operation does not involve a remote at all.

I don't think it's quite that simple. The id part of creating a commit
object is not a local operation at all. You choose the id written in a
commit for a specific remote target, it has no use locally, most of us
do not need it to reach themselves.

So yes there is a leak but it’s built in the git commit logic itself.
Ideally, git would defer resolving <me> in commits to when I push to a
remote target. I'm sure you’re aware of all the workarounds git users do
at push time, when they realize the commit <me> is not the good one.

And since the leak is built in the commit logic itself, there are no
perfect solutions that do not involve revisiting how commit works.

So, unless someone wants to revisit git commit, we’re left with
imperfect solutions, and git credentials is no worse than another. It
certainly fixes my use case fine. You did good work in git credentials.

Regards,

-- 
Nicolas Mailhot


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

* Re: [RFE] Please add name and email to git credentials
  2018-11-02 17:32               ` Nicolas Mailhot
@ 2018-11-02 17:56                 ` Jeff King
  0 siblings, 0 replies; 13+ messages in thread
From: Jeff King @ 2018-11-02 17:56 UTC (permalink / raw)
  To: Nicolas Mailhot; +Cc: git

On Fri, Nov 02, 2018 at 06:32:36PM +0100, Nicolas Mailhot wrote:

> > I did create the way git credential matches repo urls. And I do not
> > think your proposal is a good idea. The credential system is about
> > interacting with a remote URL, and creating a commit object is a local
> > operation. That mismatch leaks through when you work with multiple
> > remotes, since it is not clear which URL we would match against when
> > the operation does not involve a remote at all.
> 
> I don't think it's quite that simple. The id part of creating a commit
> object is not a local operation at all. You choose the id written in a
> commit for a specific remote target, it has no use locally, most of us
> do not need it to reach themselves.

I don't think that's true. You do not need to have a remote at all to
use Git.

But more importantly, the commit is not in any way tied to a specific
remote. You might have multiple remotes that are storing many of the
same objects. So even if you wanted to somehow assign a segment of
history to a remote, it is not an unambiguous mapping.

> So yes there is a leak but it’s built in the git commit logic itself.
> Ideally, git would defer resolving <me> in commits to when I push to a
> remote target. I'm sure you’re aware of all the workarounds git users do
> at push time, when they realize the commit <me> is not the good one.

Your second sentence is fundamentally at odds with how Git works and its
decentralized data model.

> And since the leak is built in the commit logic itself, there are no
> perfect solutions that do not involve revisiting how commit works.
> 
> So, unless someone wants to revisit git commit, we’re left with
> imperfect solutions, and git credentials is no worse than another. It
> certainly fixes my use case fine. You did good work in git credentials.

Sorry, I just don't agree with any of the logic here. That's not how
commits work in Git, and all of the solutions are not equally imperfect.

-Peff

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

end of thread, other threads:[~2018-11-02 17:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01  9:59 [RFE] Please add name and email to git credentials Nicolas Mailhot
2018-11-01 11:22 ` Ævar Arnfjörð Bjarmason
2018-11-01 12:34   ` Nicolas Mailhot
2018-11-01 13:15     ` Ævar Arnfjörð Bjarmason
2018-11-01 14:13     ` Christian Couder
2018-11-01 14:32       ` Randall S. Becker
2018-11-01 14:42       ` Nicolas Mailhot
2018-11-02  8:27         ` Christian Couder
2018-11-02  8:57           ` Nicolas Mailhot
2018-11-02 16:51             ` Jeff King
2018-11-02 17:32               ` Nicolas Mailhot
2018-11-02 17:56                 ` Jeff King
2018-11-01 11:32 ` Nicolas Mailhot

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).