Re: [PATCH] git-commit: add a prepare-commit-msg hook
From: Paolo Bonzini <hidden>
Date: 2016-06-15 22:44:06
On the other hand, if you want to always cause an action before running a git opeation locally, you do not have to have a hook. You can just prepare such a message based on GNU ChangeLog and then run git-commit with -F, both inside your wrapper.
I see two other possibilities:
1) Would you prefer allowing to run a command by setting commit.template
to something starting with an exclamation mark, i.e. something like
"!git diff --cached --name-status -r"?
2) The pre-commit could receive a file name on the command line. If it
creates that file, it would be used as a template for the commit
message. The default implementation of pre-commit could include,
commented out, a reimplementation of prepare_log_message. I like this
the least.
3) Consider that the patch, as I implemented it, does not act solely on
local data, because the index could be modified by the pre-commit hook.
This possibility is contemplated explicitly in builtin-commit.c:
/*
* Re-read the index as pre-commit hook could have updated it,
* and write it out as a tree.
*/
Paolo