TAB tricks and trivia

Re: TAB tricks and trivia

by Martín Langhoff -
Number of replies: 0
Replacing all tabs with 4 spaces across the project is probably a risky move. At the very least, it'll conflict with a lot of local/private patches people have.

So, if you want to 'clean' your patch before sending it to Martin Dougiamas, so that your patch doesn't add tabs, but doesn't change lines you didn't modify:

  # on a 'unified-diff' patch
  perl -pi -e 'if(/^\+/){s/\t/    /g}' fancynewcode.patch

Hmmm. So you've cleaned the patch, but not your CVS working copy. Not good enough, I say.

To cleanup your CVS working copy, but only on the lines you've changed...

  # update just in case
  cvs update

  # generate a patch
  cvs diff -u > mynewcode.patch

  # copy and cleanup
  cp mynewcode.patch mynewcleancode.patch
  perl -pi -e 'if(/^\+/){s/\t/    /g}' mynewcleancode.patch

  # revert the files to their unmodified state
  patch --reverse  < mynewcode.patch

  # reapply your changes, now with proper spaces
  patch < mynewcleancode.patch

Of course, this is all moot if you are using a good editor, and you have it configured to use 4 spaces instead of tabs.

cheers,





martin