0

Is there a simple way to have a diff between two versions of a file, showing only those lines/words that differ by a change to upper-/lowercase? All other differences should be omitted.

Background: I have a VBA project under version control (git) and Microsoft's editor tends to change casing every time a new variable is declared. I want to identify (and possibly count) such changes in order to prevent them from being committed.

1 Answers1

0

Based on a suggestion from this answer I have done it as follows, using basic Linux scripting tools:

GIT_EXTERNAL_DIFF='diff -p -U 0 "$2" "$5" | cat #' git diff --ext-diff >  cdiff
GIT_EXTERNAL_DIFF='diff -ip -U 0 "$2" "$5" | cat #' git diff --ext-diff > idiff

diff idiff cdiff | grep '^> [+-] ' 

The code makes first a case-sensitive diff cdiff, second a case-insensitive diff idiff. The case-only changes consist then of the lines in cdiff which are not contained in idiff.