Is it possible to get a report from git diff or related commands that excludes a certain category of change?
I've been asked to review a change where a huge number of files have undergone the equivalent of s/2016/2017/g. (We upgraded a third-party jar and as a result many of our imports now reference a different package.)
Are there options for viewing this diff from the command line but suppressing all changes that just consist of something like the following, so that I can focus on any logic changes?
Ignore:
-import com.example.2016_2.util.Utility
+import com.example.2017_2.util.Utility
Keep:
-Utility util = new Utility();
+Utility util = Utility.create();
If the answer is to write my own script and integrate via git diff --porcelain
or by setting GIT_EXTERNAL_DIFF
, I am certainly game; just wondering if
- this is supported out of the box and somehow I missed it in the man page;
- there are other git diff* commands I can use for this;
- if an appropriate diff executable already exists that I can provide via
GIT_EXTERNAL_DIFF
--word-diff
and--word-diff-regex
may help by just highlighting changes on 2016/2017 without showing the full line as changed.git diff -G<regexp>
, but while it's a great tool to select for some string, excluding one is a lot trickier with regexes.