Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] checkhf.pl fails only on pre-commit hook

From: Hadriel Kaplan <hadriel.kaplan@xxxxxxxxxx>
Date: Fri, 4 Apr 2014 23:26:09 -0400
On Apr 4, 2014, at 10:36 PM, mmann78@xxxxxxxxxxxx wrote:

> I've taken the pre-commit hook file provided in \tools and put it in my git hooks folder.  However, whenever I commit something (I've focused mostly on dissector patches and they all fail this way), it fails with "Search pattern not terminated at ./tools/checkhf.pl line 564."
> 
> When I run checkhf.pl from the Windows command-line, I don't get any errors at all.
> 
> Suggestions?  I only thing I can come up with is different a version of perl is being called from the pre-commit than from command-line.  I don't consciously have multiple versions of perl installed (in Windows), so I was wondering if others have seen (and fixed) this issue.  I would really help catch errors in case I forget to manually run the scripts because I got frustrated and "disabled" the pre-commit hook (which has happened already)

The copy of pre-commit in your .git/hooks/ directory is not tracked/managed by the git repo, so you can edit it by hand... so you could comment out the "./tools/checkhf.pl $FILE" line until this gets resolved - that way you can at least get the other checking in the meantime without resorting to disabling the whole thing.

I barely know perl, but checkhf.pl line 564 does indeed look bogus to me. (the double slashes are what it thinks is starting a regex search pattern that's not terminated I believe)

Having said that, that function shouldn't be being called/invoked, afaict.  It's only supposed to be invoked if the command to run that script uses a "--debug=<number>" or "-d <number>" option I think. And the pre-commit script does not do that. Unless $FILE is somehow a string that appears to be that option?  Try putting a 'echo $FILE' in the pre-commit script before the "./tools/checkhf.pl $FILE" line and see what it's printing out when you do 'git commit'.  Maybe something weird is going on with the 'git diff-index ... | grep ...' result?

-hadriel