How do I get a list of authors and committer IDs in a Git pre-commit hook?

It seems there is no simple way to get authors and committer IDs in a Git pre-commit hook (Missing git hooks documentation).

I can only find examples for post-commit hooks which, for example, look for spelling mistakes and then suggest

If there are errors, you can immediately fix the commit message by running git commit --amend.

which seems kind of too late.

Is there really no way to get this information in a pre-commit hook?

Answers


You can't. The commit does not yet exist so there's nothing to get.

You can come pretty close: use the same rules that git commit uses to pick a default author and committer, i.e., look for GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_COMMITTER_NAME, and GIT_COMMITTER_EMAIL in the environment, and if not set, use git config --get user.name, etc., to get the settings. But this does not seem to capture any --author= argument to a git commit command.


Need Your Help

Check if MySQL Database Exists with VB

mysql vb.net visual-studio-2012

Hi Guys i am trying to write some code to check if a MySQL Database exists and then write a line in the console if it exists or not.

SQL query for the same table

mysql oracle

I have a table in oracle with columns like ID and J_Code