commit-msg hook mistakes commit -v unified diff for part of the message

Will Thompson will.thompson at collabora.co.uk
Thu Mar 22 04:31:41 PDT 2012


Hi,

git commit takes a --verbose option, defined as follows:

>        -v, --verbose
>            Show unified diff between the HEAD commit and what would be committed at the
>            bottom of the commit message template. Note that this diff output doesn’t
>            have its lines prefixed with #.

It's very useful for making sure you're committing the right thing. 
Unfortunately, it seems that the diff output isn't stripped before the 
commit message is fed to the commit-msg hook.

I was committing a change to a README file, and the diff context 
contained the line " * for the cppunittest needed:" (followed by a line 
beginning with a "+" marking an added line). So, commit-msg saw a line 
which starts with whitespace, followed by a star, with a colon in it and 
rejected my commit message:

> Reason: Please don't use whitespace in front of '* file: Description.' entries.

I don't know whether it's possible to tweak something so that the hook 
receives the message without the unified diff; otherwise, perhaps the 
hook should stop reading lines past something which looks like a unified 
diff header.

Regards,
-- 
Will


More information about the LibreOffice mailing list