[LLVMdev] svn pre-commit hook: help needed

Duncan Sands baldrick at free.fr
Tue Feb 17 23:31:48 PST 2009


Hi Scott,

> Anyone out there interested in helping out with a subversion pre-commit hook
> to:
> 
> - remove trailing whitespace,
> - expand tabs to spaces,
> - detect 80-col violations,
> 
> as well as detect other style guideline breakage?
> 
> I just ran into the trailing whitespace problem: Eclipse and other editors
> like to trim excess whitespace from source. However, when one commits a
> patch with trailing whitespace removed, the extraneous diffs make reading
> the patch more difficult.

from the subversion manual:

"While hook scripts can do almost anything, there is one dimension in which hook script authors should show restraint: do not modify a commit transaction using hook scripts. While it might be tempting to use hook scripts to automatically correct errors, shortcomings, or policy violations present in the files being committed, doing so can cause problems. Subversion keeps client-side caches of certain bits of repository data, and if you change a commit transaction in this way, those caches become indetectably stale. This inconsistency can lead to surprising and unexpected behavior. Instead of modifying the transaction, you should simply validate the transaction in the pre-commit hook and reject the commit if it does not meet the desired requirements. As a bonus, your users will learn the value of careful, compliance-minded work habits."

Ciao,

Duncan.



More information about the llvm-dev mailing list