{"thread":{"id":"49260","subject":"feature request: allow commit.email config setting","startedAt":"2018-08-30T11:26:44Z","lastAt":"2018-08-30T19:29:44Z","messageCount":4,"participants":["Rasmus Villemoes","Junio C Hamano","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"356962","messageId":"0f66ad7a-2289-2cce-6533-a27e19945187@rasmusvillemoes.dk","threadId":"49260","inReplyTo":null,"subject":"feature request: allow commit.email config setting","fromName":"Rasmus Villemoes","fromEmail":"rv@rasmusvillemoes.dk","sentAt":"2018-08-30T11:26:38Z","receivedAt":"2018-08-30T11:26:44Z","isPatch":false,"sender":{"key":"rv@rasmusvillemoes.dk","avatar":"https://avatars.githubusercontent.com/u/4375908?v=4"},"body":"As part of my dayjob, I did and still do some work on an upstream\nproject. A while ago, I was granted commit access to that project.\nHowever, upstream asked that I would register with their system using a\nprivate email, or at least one that wouldn't change if I changed jobs,\nrather than my work email.\n\nNow, I (and my employer) would like that the work I do as part of my\ncurrent job on that project has my work email in the Author field, but\nsince the commit access was granted to me privately/personally, it would\nbe nice if the Committer email was the one I used to register with their\nsystem. I can set GIT_COMMITTER_EMAIL in the environment, but that is\nrather inconvenient, since that means I have to remember to do that in\nthe shell I'm using for that particular project, and I can't use that\nshell for other projects. So it would be really nice if I could set\ncommit.email = $private-email in the local .git/config for that\nparticular project. I don't personally have a use for commit.name (when\nmissing, that should just use user.name as usual), but it would probably\nbe most consistent to allow that too.\n\nI tried looking into ident.c, but it doesn't seem like it is\nstraight-forward to implement. Probably fmt_ident, ident_default_email\netc. would need to be passed information about what purpose the ident is\nto be used for. So before trying to implement this, I want to hear if\nthis is a reasonable thing to support. Also, I'm sure there are some\nsubtle semantics that would need to be decided and gotchas to watch out for.\n\nRasmus\n"},{"id":"356985","messageId":"xmqq8t4n7twg.fsf@gitster-ct.c.googlers.com","threadId":"49260","inReplyTo":"0f66ad7a-2289-2cce-6533-a27e19945187@rasmusvillemoes.dk","subject":"Re: feature request: allow commit.email config setting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-08-30T15:31:43Z","receivedAt":"2018-08-30T15:31:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Rasmus Villemoes <rv@rasmusvillemoes.dk> writes:\n\n> ... I can set GIT_COMMITTER_EMAIL in the environment, but that is\n> rather inconvenient, since that means I have to remember to do that in\n> the shell I'm using for that particular project, and I can't use that\n> shell for other projects.\n\nWe only have user.email and user.name because nobody in the past 10+\nyears had such a requirement, but I find it it a perfectly sensible\nthing to wish to say \"tagger.email and tagger.name are used while\ncreating an annotated tag, committer.email and committer.name are\nused on the 'committer' line and author.email and author.name are\nused on the 'author' line in a newly created commit; by the way, if\nany of these are not set, but user.email or user.name is set, then\nthey are used as fallback values.\" at the design level.\n\n\n"},{"id":"356995","messageId":"CAPig+cTnvDfYaDh7JSXXGGA=+DE4WAiuTZEKpxv67u1_OyT-qA@mail.gmail.com","threadId":"49260","inReplyTo":"0f66ad7a-2289-2cce-6533-a27e19945187@rasmusvillemoes.dk","subject":"Re: feature request: allow commit.email config setting","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-08-30T18:13:32Z","receivedAt":"2018-08-30T18:13:46Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Aug 30, 2018 at 7:26 AM Rasmus Villemoes <rv@rasmusvillemoes.dk> wrote:\n> I can set GIT_COMMITTER_EMAIL in the environment, but that is\n> rather inconvenient, since that means I have to remember to do that in\n> the shell I'm using for that particular project, and I can't use that\n> shell for other projects. So it would be really nice if I could set\n> commit.email = $private-email in the local .git/config for that\n> particular project.\n\nAside from modifying Git itself to support such a use-case, another\n(perhaps more pragmatic) approach would be to use a tool, such as\ndirenv[1], which automatically sets environment variables for you\ndepending upon your current working directory, or just use some ad-hoc\nshell programming to achieve the same (for instance, [2]).\n\n[1]: https://direnv.net\n[2]: https://stackoverflow.com/questions/14462591/set-environmental-variables-in-a-particular-directory\n"},{"id":"357007","messageId":"cba5b445-2208-7a01-5ea6-7a3590cef50e@rasmusvillemoes.dk","threadId":"49260","inReplyTo":"CAPig+cTnvDfYaDh7JSXXGGA=+DE4WAiuTZEKpxv67u1_OyT-qA@mail.gmail.com","subject":"Re: feature request: allow commit.email config setting","fromName":"Rasmus Villemoes","fromEmail":"rv@rasmusvillemoes.dk","sentAt":"2018-08-30T19:29:37Z","receivedAt":"2018-08-30T19:29:44Z","isPatch":false,"sender":{"key":"rv@rasmusvillemoes.dk","avatar":"https://avatars.githubusercontent.com/u/4375908?v=4"},"body":"On 2018-08-30 20:13, Eric Sunshine wrote:\n> On Thu, Aug 30, 2018 at 7:26 AM Rasmus Villemoes <rv@rasmusvillemoes.dk> wrote:\n>> I can set GIT_COMMITTER_EMAIL in the environment, but that is\n>> rather inconvenient, since that means I have to remember to do that in\n>> the shell I'm using for that particular project, and I can't use that\n>> shell for other projects. So it would be really nice if I could set\n>> commit.email = $private-email in the local .git/config for that\n>> particular project.\n> \n> Aside from modifying Git itself to support such a use-case, another\n> (perhaps more pragmatic) approach would be to use a tool, such as\n> direnv[1], which automatically sets environment variables for you\n> depending upon your current working directory, or just use some ad-hoc\n> shell programming to achieve the same (for instance, [2]).\n\nThanks for the hint! I've actually had \"git\" as a function in my .bashrc\nfor a long time, for implementing a ~/.githistory to help remember the\nsometimes rather complex git invocations, and keeping track of the\ncontext ($cwd, current branch, etc.) they were used in. It should be\ntrivial to hook the environment settings based on $cwd into that. The\nonly problem is that that gives me much less incentive to work on\nimplementing the config support in git, but if I'm the only one with a\nuse case, that's probably just as well.\n\nRasmus\n\n"}]}