git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jaseem abid <jaseemabid@gmail.com>
To: Andrew Sayers <andrew-git@pileofstuff.org>
Cc: git mailing list <git@vger.kernel.org>
Subject: Re: Arguments to git hooks
Date: Tue, 15 May 2012 02:04:19 +0530	[thread overview]
Message-ID: <CAH-tXsBMYe2q6dZ6COyEH7N9n-mJh4yV8O50tgeZ1PeSEnZHvQ@mail.gmail.com> (raw)
In-Reply-To: <4FA84A0F.6060608@pileofstuff.org>

On Tue, May 8, 2012 at 3:47 AM, Andrew Sayers
<andrew-git@pileofstuff.org> wrote:
> On 06/05/12 19:35, jaseem abid wrote:
>> Hello all,
>>
>> 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?
>
> First, a standard warning - consider using a pre-receive hook instead of
> a pre-commit hook.

I am trying to get a lint, commit message spell checker, trailing
whitespace check in code etc work on my *local machine* before
committing. pre-receive works in the server right? Its also time I
need to seriously consider a pre-commit hook to "Reject commits made
between 4am and 7am with a note to go to bed."

> A lot of git's power comes from making commits as
> cheap as possible, so rules like "no committing until your code is
> pretty" tend to stifle people.

Its ok since I am the only one to use it because I want to make my
commits cleaner and better.  There is always --no-verify for skipping
hooks.

> The best solution I've found is a `git commit` wrapper that does
> something like `CHANGES="$(git commit $@ --dry-run -v)"` to get a
> reliable diff, then starts work from there.

Isn't `git commit $@ --dry-run --porcelain` better for parsing or am I
missing something ?

-- 
Jaseem Abid
http://jaseemabid.github.com

      reply	other threads:[~2012-05-14 20:35 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
2012-05-07 22:17 ` Andrew Sayers
2012-05-14 20:34   ` jaseem abid [this message]

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=CAH-tXsBMYe2q6dZ6COyEH7N9n-mJh4yV8O50tgeZ1PeSEnZHvQ@mail.gmail.com \
    --to=jaseemabid@gmail.com \
    --cc=andrew-git@pileofstuff.org \
    --cc=git@vger.kernel.org \
    /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).