Xprog
Xprog

Reputation: 901

svn diff whitespace/tab changes only

Is there way in svn diff or any other tool(linux based) to show only whitespace/tabs changes ?.

Purpose, I dont want those diffs to be checked in. I can put back those lines to same state before check in if a tool could catch those diffs.

Thanks,

Upvotes: 4

Views: 2172

Answers (3)

Kevin Smyth
Kevin Smyth

Reputation: 1937

A couple improvements for @mfisch's script: only work on files with text modifications, and support filenames with spaces.

#!/bin/bash

svn status | grep ^M | sed 's/^........//' |
while read -r file
do
    COUNT=$(svn diff "$file" --diff-cmd 'diff' -x '-w' | wc -l)
    if [ $COUNT -le 2 ]
    then
       echo "$file has only whitespace changes"
       # svn revert "$file"
    fi
done

Upvotes: 2

mfisch
mfisch

Reputation: 989

This should work for you.

#!/bin/bash

FILES=`svn status | awk '{ print $2}'`
for file in $FILES
do
    COUNT=`svn diff $file --diff-cmd 'diff' -x '-w' | wc -l`
    if [ $COUNT -le 2 ]
    then
       echo "$file has only whitespace changes"
    fi
done

Also, instead of putting lines back to the same state, why not just revert those files?

Upvotes: 5

Moose
Moose

Reputation: 5412

Beyond Compare will show those highlighted in a different color depending on the type of file. they do have a Linux version, but I have not used it. It is a great diff tool though.

Upvotes: 0

Related Questions