help with bogus "pre-commit hook failure"

Hi all,

I’m trying to submit a simple one line patch, but committing gives me:

[attr]our-c-style  whitespace=tab-in-indent,no-lf-at-eof  hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
[attr]our-c-style  whitespace=tab-in-indent,no-lf-at-eof  hooks.style=KWStyle,clangformat
 not allowed: ./.gitattributes:31
Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx:47: error: Unnecessary semicolon
Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx:130: error: Unnecessary semicolon
pre-commit hook failure
1 Like

Hi @seanm,
although I have not contributed since it was put in place, a new pre-commit hook that checks the style was put in place recently.

May be you will need to configure the tool so that it automatically enforces the adopted style.

Strange, it seems to have chopped off half my message. The second half was:

KWStyle check failed.

Line numbers in the errors shown refer to the file:
Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx.kws

If I remove the “unnecessary” semi-colon at line 47 compilation fails.

How do I bypass this?

Thanks,

Sean

May be the style format document needs to be revisited/does not handle properly this use case?

You should modify this file:

Note that the one line I’m trying to change is not the lines it’s complaining about. It complains about 2 different lines that I’ve not touched.

Bradley, what format is that file and how exactly should it be edited in my case?

This is an error can that occur with an older version of KWStyle that did not support C++11.

To confirm the KWStyle executable used:

cd ~/src/ITK
git config hooks.KWStyle.path

You may find that it is pointing to an older executable.

Next time ITK is built, it will build KWStyle and configure Git to use the that version, which is new enough.

Alternatively, disable the KWStyle hook temporarily with:

git config hook.KWStyle false

or skip the pre-commit hooks with:

git commit -n

Thanks Matt. Indeed I had some random build of KWStyle. git commit -n did the trick.

1 Like

Matt, I just did a fresh vanilla build of ITK, and commits still fail. Where is the automagical build of KWStyle supposed to be? I doesn’t seem to get created for me.

This should take care of building KWStyle:


and it is included from here:

1 Like