git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Szakmeister <john@szakmeister.net>
To: Neal Kreitzinger <nkreitzinger@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: pre-commit hook to reject whitespace
Date: Fri, 3 Jun 2011 20:12:45 -0400	[thread overview]
Message-ID: <BANLkTi=Gh9CStVkgp5gBs7XzG-dCXB+oUw@mail.gmail.com> (raw)
In-Reply-To: <isbsf8$6id$1@dough.gmane.org>

On Fri, Jun 3, 2011 at 7:58 PM, Neal Kreitzinger <nkreitzinger@gmail.com> wrote:
> On 6/3/2011 6:31 PM, Neal Kreitzinger wrote:
>>
>> The reference manuals state in the hooks documentation that the pre-commit
>> hook sample will reject whitespace only changes.  However, the
>> pre-commit.sample in the 1.7.1 and 1.7.5.4 downloads do not appear to do
>> this (I'm new to linux scripts).  The appear to only reject non-ascii
>> filenames.  Does someone have a pre-commit hook example I can use to
>> reject
>> whitespace-only changes?  Thanks!
>>
> As someone kindly pointed out, the documentation actually says:
> "The default 'pre-commit' hook, when enabled, catches introduction of lines
> with trailing whitespaces and aborts the commit when such a line is found."
>
> I'm not seeing this functionality in the pre-commit.sample for 1.7.1 or
> 1.7.5.4.

I've never tried that hook script myself, but it appears to be on the last line:
   exec git diff-index --check --cached $against --

In particular, the --check option says:
    Warn if changes introduce trailing whitespace or an indent that
uses a space before a tab. Exits with non-zero status if problems are
found. Not compatible with --exit-code.

HTH!

-John

  reply	other threads:[~2011-06-04  0:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 23:31 pre-commit hook to reject whitespace Neal Kreitzinger
2011-06-03 23:58 ` Neal Kreitzinger
2011-06-04  0:12   ` John Szakmeister [this message]
2011-06-04  0:23     ` Neal Kreitzinger

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='BANLkTi=Gh9CStVkgp5gBs7XzG-dCXB+oUw@mail.gmail.com' \
    --to=john@szakmeister.net \
    --cc=git@vger.kernel.org \
    --cc=nkreitzinger@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).