git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Menzel <paulepanter@users.sourceforge.net>
To: git@vger.kernel.org
Subject: Looking for pre-commit hook to check whitespace errors but not for all files
Date: Sat, 14 Dec 2013 16:28:14 +0100	[thread overview]
Message-ID: <1387034894.4636.9.camel@mattotaupa> (raw)

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]

Dear git folks,


in coreboot we try to check for whitespace errors before committing. Of
course a pre-commit hook is the way to go, but unfortunately it is not
so simple (at least for me) as the following requirements exist.

1. Only the files actually committed should be checked. That means
running `git commit -a`, abort that and then running `git commit
some/file` should only check `some/file` for whitespace errors.

2. There are certain files that are allowed to have whitespace errors.
In our case these are `*.patch` and `*.diff` files which by design seem
to contain whitespace error.

Currently the whole tree is checked, which takes a lot of time [1].

I tried to come up with a patch [2], but failed so far. Best would be to
have

    $ git diff --check --only-committed-files --exclude "*patch$"

where I could not find a way for the last to switches.

Currently, I would use

    $ git diff-index --cached --name-only $against -- | grep -v patch$

and pass that list to some whitespace check program. Unfortunately that
still does not fulfill the first requirement.

What am I missing to solve this elegantly?


Thanks,

Paul


[1] http://review.coreboot.org/gitweb?p=coreboot.git;a=blob;f=util/lint/lint-stable-003-whitespace;h=1e824a1e76e37ce641b91c75f2f78e0e2abfd37f;hb=HEAD
[2] http://review.coreboot.org/#/c/3340/

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

             reply	other threads:[~2013-12-14 16:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-14 15:28 Paul Menzel [this message]
2013-12-14 16:59 ` Looking for pre-commit hook to check whitespace errors but not for all files John Keeping
2013-12-16 19:06 ` Junio C Hamano

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=1387034894.4636.9.camel@mattotaupa \
    --to=paulepanter@users.sourceforge.net \
    --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).