git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jakub Narebski <jnareb@gmail.com>
Cc: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>, git@vger.kernel.org
Subject: Re: "commit --author=..." does not work if global email and name is not set
Date: Mon, 08 Apr 2019 15:57:18 +0900	[thread overview]
Message-ID: <xmqq36mt9e7l.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <8636mvng8n.fsf@gmail.com> (Jakub Narebski's message of "Sat, 06 Apr 2019 20:25:12 +0200")

Jakub Narebski <jnareb@gmail.com> writes:

> As Junio said, the "--author=<author name and email>" sets the author
> identity, but not the committer identity; you can work around the issue
> with "git -c user.name=me -c user.email=me@email.my".

Having slept on this a bit, I am of two minds here.

It certainly is possible to change the rule to say that committer
identity, when not set at all, takes the default from the author
identity, if and only if the latter is explicitly given, and that
would certainly make it work as Piotr wanted to.

But then, that is only valid if the users use --author with the
author make that refers to self every time s/he makes a commit.  I
am not sure if that is a plausible use case.  The command line
option "--author" is really meant to be used one-off to name
somebody other than self in a rare occasion.  Use of --author that
breaks the built-in safety of committing under undesired identity
(e.g. "<user@localhost>") without realizing before the mistake is
buried deep in the history may not be such a goodidea.

> Better though is to focus on what you want, namely to prevent accidental
> commits without specified author, instead of how you want to achieve it,
> i.e. using --author to provide both author and committer identity (the
> XY problem).  On that machine with "automatic test account" set up
> pre-commit or commit-msg hook that fails if the GIT_AUTHOR_IDENT
> environment variable is not the "automatic test account".

It could be s/is not/is/ perhaps, but I do like the line of
reasoning and where it leads us.  "To prevent mistakes" is something
hooks are good for.

Thanks.

  reply	other threads:[~2019-04-08  6:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-05  7:34 "commit --author=..." does not work if global email and name is not set Piotr Krukowiecki
2019-04-05  8:11 ` Junio C Hamano
2019-04-06 18:25 ` Jakub Narebski
2019-04-08  6:57   ` Junio C Hamano [this message]
2019-04-08  9:54     ` Piotr Krukowiecki
2019-04-08 11:06       ` Jakub Narebski
2019-04-08 11:55         ` Piotr Krukowiecki
2019-04-09  6:31           ` Junio C Hamano
2019-04-09  7:03             ` Piotr Krukowiecki
2019-04-09  7:43           ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq36mt9e7l.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=piotr.krukowiecki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).