git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* improvement to pre-commit hook
@ 2019-05-19  6:03 Olegzandr von Denman (ORESoftware)
  2019-05-20 23:45 ` brian m. carlson
  0 siblings, 1 reply; 2+ messages in thread
From: Olegzandr von Denman (ORESoftware) @ 2019-05-19  6:03 UTC (permalink / raw)
  To: git

I was expected an env var like:

GIT_DESIRED_COMMIT_MESSAGE

to show up when .git/hooks/pre-commit is run

but as described here, there doesn't appear to be any args to the
script and the environment variable isn't there?

https://stackoverflow.com/questions/56205170/retrieving-desired-git-commit-message-in-pre-commit-hook

-alex

-- 
Alexander Mills
ORESoftware (inc.)

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

* Re: improvement to pre-commit hook
  2019-05-19  6:03 improvement to pre-commit hook Olegzandr von Denman (ORESoftware)
@ 2019-05-20 23:45 ` brian m. carlson
  0 siblings, 0 replies; 2+ messages in thread
From: brian m. carlson @ 2019-05-20 23:45 UTC (permalink / raw)
  To: Olegzandr von Denman (ORESoftware); +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]

On 2019-05-19 at 06:03:11, Olegzandr von Denman (ORESoftware) wrote:
> I was expected an env var like:
> 
> GIT_DESIRED_COMMIT_MESSAGE
> 
> to show up when .git/hooks/pre-commit is run
> 
> but as described here, there doesn't appear to be any args to the
> script and the environment variable isn't there?
> 
> https://stackoverflow.com/questions/56205170/retrieving-desired-git-commit-message-in-pre-commit-hook

In general, the pre-commit hook isn't the right place to inspect the
commit message. If the user hasn't specified the commit message on the
command line, then they will be prompted for it using their editor, and
there will be nothing to process.

Furthermore, since the prepare-commit-msg hook hasn't run, there could
be arbitrary changes to the commit message after the pre-commit hook
runs. You'd want to use the prepare-commit-msg hook to modify the commit
message and then use the commit-msg hook to accept or reject it. Despite
the name, the commit-msg hook can be used to perform arbitrary analysis
of the commit and reject it for any reason if you require the commit
message to do so.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

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

end of thread, other threads:[~2019-05-20 23:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-19  6:03 improvement to pre-commit hook Olegzandr von Denman (ORESoftware)
2019-05-20 23:45 ` brian m. carlson

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