Skip to content
  • thewtex's avatar
    pre-commit: Apply uncrustify and KWStyle check for modified files. · d5bb0764
    thewtex authored
    uncrustify (uncrustify.sourceforge.net) is applied to changed files prior to
    commit.
    
    This feature is off by default.  To enable this behavior, set
    
      git config hooks.uncrustify true
    
    By default, the behavior of git-mergetool is used to review the changes
    uncrustify makes before they are added to the commit.  For more information on
    this behavior, see
    
      git help mergetool
    
    KWStyle is run on the changed C++ files and the commit is aborted if the files
    do not pass the test.  A file similar to the original is saved with a '*.kws'
    extension so that line numbers referenced in the error message can be examined.
    
    The test is off by default.  To enable this behavoir, set
    
      git config hooks.KWStyle true
    
    Project specific uncrustify and KWStyle configuration files are set with 'git
    config'.  For example,
    
      git config hooks.uncrustify.conf path/to/uncrustify.conf
      git config hooks.KWStyle.conf path/to/KWStyle.conf
      git config hooks.KWStyle.overwriteRulesConf path/to/overwrite.conf # optional
    
    If the appropriate values have not been set, die() is called.  An
    optional KWStyle overwrite rules file can also been configured.
    
    The files on which to run the style checks must also be identified in the
    repository's '.gitattributes'.  For example,
    
      *.h    hooks.style
      *.cpp  hooks.style
    
    Or, to only enable a subset of style hooks,
    
      *.h    hooks.style=KWStyle
      *.cpp  hooks.style=KWStyle,uncrustify
    
    Change-Id: Ia6b2d4136af3002eb0ec5d36f03c50df928917f4
    d5bb0764