git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
To: Jakub Narebski <jnareb@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: "commit --author=..." does not work if global email and name is not set
Date: Mon, 8 Apr 2019 13:55:25 +0200	[thread overview]
Message-ID: <CAA01CspJAPnBFsQsXP4Dpweeg6oBVj==TB0aEnK5o1Et5zS30Q@mail.gmail.com> (raw)
In-Reply-To: <86y34kn4c8.fsf@gmail.com>

On Mon, Apr 8, 2019 at 1:06 PM Jakub Narebski <jnareb@gmail.com> wrote:
>
> Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:
>
> >> On Sat, Apr 6, 2019 at 8:25 PM Jakub Narebski <jnareb@gmail.com> wrote:
> >>>
> >>> 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".
> >
> > I'm not sure if I follow you. I want to be able to make both "real
> > user" and "automatic test account user" commits from that machine. I
> > want to make sure that:
> > - automatic commits (scripts) use their own account
> > - real person making commit uses their own account
> >
> > IMO the only way this can be achieved is by not having any default
> > account setup, so that both the scripts and the real users need to
> > specify it "by hand".
>
> If a real person making commits uses their own account (just on that
> machine), he or she can set up `user.name` and `user.email` settings in
> the per-user Git configuration file

There is one common "test" (Windows) account which is used both by
automatic test scripts and by real people who log into that machine,
so this is not possible.


> If however one is doing commits from the "automatic test user" account,
> then the `pre-commit` or `commit-msg` hook configured for that specific
> repository for that automatic account would be run, which can detect
> that the commit was not done with
>
>   $ git commit --author="My Name <me@my.email.com>"
>
> The additional advantage is that you can examine committer data to
> detect such cases of committing out of automatic account.

Do you mean following?

1. set default user (user.name, user.email) to "automatic test user"
on that machine
2. set commit hook to prevent commits with "automatic test user" AUTHOR
3. scripts will set AUTHOR (--author) to for example "script X" or
"automatic script user" - different than the default user
4. real users will set AUTHOR to their own identity (--author=me)

I suppose that would work. Looks much more complicated than simply
setting "--author" (or "--user") though...


-- 
Piotr Krukowiecki

  reply	other threads:[~2019-04-08 11:55 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
2019-04-08  9:54     ` Piotr Krukowiecki
2019-04-08 11:06       ` Jakub Narebski
2019-04-08 11:55         ` Piotr Krukowiecki [this message]
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='CAA01CspJAPnBFsQsXP4Dpweeg6oBVj==TB0aEnK5o1Et5zS30Q@mail.gmail.com' \
    --to=piotr.krukowiecki@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@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).