git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: jaseem abid <jaseemabid@gmail.com>
Cc: git mailing list <git@vger.kernel.org>
Subject: Re: Arguments to git hooks
Date: Mon, 7 May 2012 03:15:41 -0400	[thread overview]
Message-ID: <20120507071541.GA19874@sigill.intra.peff.net> (raw)
In-Reply-To: <CAH-tXsB4PBS_YjW4DCjT6ORmNPomQ8XMPbKx3hxVNH=FyB2u3g@mail.gmail.com>

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

  parent reply	other threads:[~2012-05-07  7:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-06 18:35 Arguments to git hooks jaseem abid
2012-05-06 19:12 ` Marcus Karlsson
2012-05-06 19:18   ` jaseem abid
2012-05-06 21:11     ` Marcus Karlsson
2012-05-06 21:40       ` jaseem abid
2012-05-07  7:21         ` Jeff King
2012-05-07  7:15 ` Jeff King [this message]
2012-05-07 22:17 ` Andrew Sayers
2012-05-14 20:34   ` jaseem abid

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=20120507071541.GA19874@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=jaseemabid@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).