git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* feature request: allow commit.email config setting
@ 2018-08-30 11:26 Rasmus Villemoes
  2018-08-30 15:31 ` Junio C Hamano
  2018-08-30 18:13 ` Eric Sunshine
  0 siblings, 2 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2018-08-30 11:26 UTC (permalink / raw)
  To: Git Mailing List

As part of my dayjob, I did and still do some work on an upstream
project. A while ago, I was granted commit access to that project.
However, upstream asked that I would register with their system using a
private email, or at least one that wouldn't change if I changed jobs,
rather than my work email.

Now, I (and my employer) would like that the work I do as part of my
current job on that project has my work email in the Author field, but
since the commit access was granted to me privately/personally, it would
be nice if the Committer email was the one I used to register with their
system. I can set GIT_COMMITTER_EMAIL in the environment, but that is
rather inconvenient, since that means I have to remember to do that in
the shell I'm using for that particular project, and I can't use that
shell for other projects. So it would be really nice if I could set
commit.email = $private-email in the local .git/config for that
particular project. I don't personally have a use for commit.name (when
missing, that should just use user.name as usual), but it would probably
be most consistent to allow that too.

I tried looking into ident.c, but it doesn't seem like it is
straight-forward to implement. Probably fmt_ident, ident_default_email
etc. would need to be passed information about what purpose the ident is
to be used for. So before trying to implement this, I want to hear if
this is a reasonable thing to support. Also, I'm sure there are some
subtle semantics that would need to be decided and gotchas to watch out for.

Rasmus

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

* Re: feature request: allow commit.email config setting
  2018-08-30 11:26 feature request: allow commit.email config setting Rasmus Villemoes
@ 2018-08-30 15:31 ` Junio C Hamano
  2018-08-30 18:13 ` Eric Sunshine
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2018-08-30 15:31 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: Git Mailing List

Rasmus Villemoes <rv@rasmusvillemoes.dk> writes:

> ... I can set GIT_COMMITTER_EMAIL in the environment, but that is
> rather inconvenient, since that means I have to remember to do that in
> the shell I'm using for that particular project, and I can't use that
> shell for other projects.

We only have user.email and user.name because nobody in the past 10+
years had such a requirement, but I find it it a perfectly sensible
thing to wish to say "tagger.email and tagger.name are used while
creating an annotated tag, committer.email and committer.name are
used on the 'committer' line and author.email and author.name are
used on the 'author' line in a newly created commit; by the way, if
any of these are not set, but user.email or user.name is set, then
they are used as fallback values." at the design level.



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

* Re: feature request: allow commit.email config setting
  2018-08-30 11:26 feature request: allow commit.email config setting Rasmus Villemoes
  2018-08-30 15:31 ` Junio C Hamano
@ 2018-08-30 18:13 ` Eric Sunshine
  2018-08-30 19:29   ` Rasmus Villemoes
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Sunshine @ 2018-08-30 18:13 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: Git List

On Thu, Aug 30, 2018 at 7:26 AM Rasmus Villemoes <rv@rasmusvillemoes.dk> wrote:
> I can set GIT_COMMITTER_EMAIL in the environment, but that is
> rather inconvenient, since that means I have to remember to do that in
> the shell I'm using for that particular project, and I can't use that
> shell for other projects. So it would be really nice if I could set
> commit.email = $private-email in the local .git/config for that
> particular project.

Aside from modifying Git itself to support such a use-case, another
(perhaps more pragmatic) approach would be to use a tool, such as
direnv[1], which automatically sets environment variables for you
depending upon your current working directory, or just use some ad-hoc
shell programming to achieve the same (for instance, [2]).

[1]: https://direnv.net
[2]: https://stackoverflow.com/questions/14462591/set-environmental-variables-in-a-particular-directory

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

* Re: feature request: allow commit.email config setting
  2018-08-30 18:13 ` Eric Sunshine
@ 2018-08-30 19:29   ` Rasmus Villemoes
  0 siblings, 0 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2018-08-30 19:29 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List

On 2018-08-30 20:13, Eric Sunshine wrote:
> On Thu, Aug 30, 2018 at 7:26 AM Rasmus Villemoes <rv@rasmusvillemoes.dk> wrote:
>> I can set GIT_COMMITTER_EMAIL in the environment, but that is
>> rather inconvenient, since that means I have to remember to do that in
>> the shell I'm using for that particular project, and I can't use that
>> shell for other projects. So it would be really nice if I could set
>> commit.email = $private-email in the local .git/config for that
>> particular project.
> 
> Aside from modifying Git itself to support such a use-case, another
> (perhaps more pragmatic) approach would be to use a tool, such as
> direnv[1], which automatically sets environment variables for you
> depending upon your current working directory, or just use some ad-hoc
> shell programming to achieve the same (for instance, [2]).

Thanks for the hint! I've actually had "git" as a function in my .bashrc
for a long time, for implementing a ~/.githistory to help remember the
sometimes rather complex git invocations, and keeping track of the
context ($cwd, current branch, etc.) they were used in. It should be
trivial to hook the environment settings based on $cwd into that. The
only problem is that that gives me much less incentive to work on
implementing the config support in git, but if I'm the only one with a
use case, that's probably just as well.

Rasmus


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

end of thread, other threads:[~2018-08-30 19:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-30 11:26 feature request: allow commit.email config setting Rasmus Villemoes
2018-08-30 15:31 ` Junio C Hamano
2018-08-30 18:13 ` Eric Sunshine
2018-08-30 19:29   ` Rasmus Villemoes

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).