git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFE] Please add name and email to git credentials

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 1, 2018, 13:15 UTC
Message-ID
<87wopxj5wr.fsf@evledraar.gmail.com>
In-Reply-To
<6f3d8c49e1d44ab20d4169e5254364cba707f1af.camel@laposte.net>
On Thu, Nov 01 2018, Nicolas Mailhot wrote:
Show 32 quoted lines
> 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
Previous: Nicolas MailhotNext: Christian Couder
Message 4 of 13 in “[RFE] Please add name and email to git credentials”
  1. Nicolas MailhotNov 1, 2018
  2. Ævar Arnfjörð BjarmasonNov 1, 2018
  3. Nicolas MailhotNov 1, 2018
  4. Ævar Arnfjörð BjarmasonNov 1, 2018
  5. Christian CouderNov 1, 2018
  6. Nicolas MailhotNov 1, 2018
  7. Christian CouderNov 2, 2018
  8. Nicolas MailhotNov 2, 2018
  9. Jeff KingNov 2, 2018
  10. Nicolas MailhotNov 2, 2018
  11. Jeff KingNov 2, 2018
  12. Randall S. BeckerNov 1, 2018
  13. Nicolas MailhotNov 1, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.