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.

  • how to implement git id or build to c# application
  • Should these auxiliary files be under Git version control?
  • SmartGit (git) ghost modifications
  • What data is being signed when you `git commit --gpg-sign=<key-id>`?
  • Git client on the iPhone, possible? How?
  • Pushing to bitbucket with libgit2sharp
  • 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.

  • git diff <fileName> showing changes for new branch and old branch
  • Is it possible to use GitHub and GitLab on one machine?
  • git “loose object … is corrupt” - what data have I lost?
  • git push/clone to new server
  • Git for Windows: get older verisons of file?
  • octopress the first commit
  • 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
        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.

    Git Baby is a git and github fan, let's start git clone.