Enforcing coding style with pre-receive Git hook
I am working on an embedded Linux project with a small team, and we have decided to enforce a C coding style. We have chosen the Linux Kernel coding style, and we use the script provided in the Kernel tree checkpatch.pl to check our patches.
We would like to check the coding style before accepting a patch on the server, using a pre-receive hook. However, we cannot find a reliable script that does this job, specially when branches are created and deleted.
May we solve this problem via Git remote hooks? Specifically, we need to check all the modified files by a commit (or series of commit) with checkpatch.pl.
One Solution collect form web for “Enforcing coding style with pre-receive Git hook”
You can see in this gist an example of detection of branches being deleted or created
case "$refname" in refs/heads/*) branch=$(expr "$refname" : "refs/heads/\(.*\)") if [ 0 -ne $(expr "$newrev" : "0*$") ]; then # deleting ... else #updating if [ 0 -ne $(expr "$oldrev" : "0*$") ]; then # pushing a new branch
You should be to adapt that in order to manage your coding style check.