[Ovirt-devel] a pox on whitespace

Jim Meyering jim at meyering.net
Wed Jul 16 17:21:46 UTC 2008


Here are some things we can do to avoid
bad whitespace (not just trailing whitespace)
without causing too much development pain:

server-side enforcement
  have a git pre-push hook check for and reject changes that
  add trailing blanks.  This typically cannot be circumvented.
  However, I've set up similar things whereby exceptional cases
  can be white-listed.

local-commit-enforcement
  With recent git, just do this in each of your
  working directories:  chmod a+x .git/hooks/pre-commit
  and a commit that would have added bad whitespace will fail.
  (you can circumvent it with git commit's --no-verify (-n) option)

"make check"-style detection
  Add a top-level Makefile rule that fails if any file
  contains bad whitespace.  Then establish policy that one must
  pass "make check"s tests before committing/pushing.

editor highlighting
  Enable syntax highlighting in your editor and tell it to
  display bad whitespace.  For example, add this to your ~/.vimrc:

    let c_space_errors=1
    highlight RedundantSpaces ctermbg=red guibg=red
    match RedundantSpaces /\s\+$\| \+\ze\t/

For emacs, you might want to try show-wspace.el (I haven't,
but it's the first google hit for "highlight whitespace emacs")
<http://www.emacswiki.org/cgi-bin/wiki/show-wspace.el>, or maybe
you already use font-lock mode, which you can customize.

Jim




More information about the ovirt-devel mailing list