Automate a checkpatch run on commit


The material has been taken from here (author is Stefan Hajnoczi).

How to automatically run when developing QEMU

The script was recently added to qemu.git as a way to scan patches for coding standard violations. You can automatically run when committing changes to git and abort if there are violations:

$ cd qemu
$ cat >.git/hooks/pre-commit
exec git diff --cached | scripts/ --no-signoff -q -
$ chmod 755 .git/hooks/pre-commit

Any commit that violates the coding standard as checked by will be aborted. I am running with this git hook now and will post any tweaks I make to it.
Update : If you encounter a false positive because is complaining about code you didn't touch, use git commit --no-verify to override the pre-commit hook. Use this trick sparingly :-).

Updated by Sergey Smolov over 4 years ago · 1 revisions