Thread (9 messages) flat view 9 messages, 4 authors, 2016-06-15

Re: Arguments to git hooks

From: Jeff King <hidden>
Date: 2016-06-15 22:53:45

On Mon, May 07, 2012 at 12:05:51AM +0530, jaseem abid wrote:
I am trying to write a hook '.git/hooks/commit-msg' to be run before
every commit.

How can I pass arguments to the script? Now by default the only arg I
am getting is `.git/COMMIT_EDITMSG'`. I would love to get the list of
files I tried to commit also into the script so that I can run a lint
program on it before committing it. How can I get this done?
It sounds like you want the "pre-commit" hook rather than "commit-msg".

But that aside, the solution is to use plumbing commands to examine the
state. You probably want "git diff-index --cached --name-only" to get
the list of files that are being committed.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help