[PATCH 0/2] diff: add -I<regex> that ignores matching changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch series adds a new diff option that enables ignoring changes
whose all lines (changed, removed, and added) match a given regular
expression.  This is similar to the -I option in standalone diff
utilities and can be used e.g. to look for unrelated changes in commits
containing a large number of automatically applied modifications (e.g. a
tree-wide string replacement).  The difference between -G/-S and the new
-I option is that the latter filters output on a per-change basis.

I personally found this feature handy quite a few times while reviewing
patches and a quick web search yields some questions from other people
looking for something like this, so I thought I would take a shot at
submitting it upstream.

Please note that while this patch series in its current shape builds,
seems to pass tests, and appears to work as I would expect it to, this
is my first attempt at contributing to Git and I did come across a few
stumbling blocks:

  - Instead of adding an extra flag for 'xdl_opts', would it be better
    to make sure xpparam_t structures are always zero-initialized before
    xdl_diff() is called (see commit message for patch 1 for context)?

  - If this patch series is accepted, should xdl_mark_ignorable() be
    renamed to something like xdl_mark_ignorable_blank() for slightly
    improved code clarity?

  - Would a more thorough explanation of the option help or hurt?

  - Given that hunk emitting rules are the same for the -I option
    proposed in this patch series as for --ignore-blank-lines, is it
    necessary to duplicate the (impressively extensive!)
    --inter-hunk-context tests in t/t4015-diff-whitespace.sh for -I?  I
    decided against doing that for the time being (though I did add some
    basic tests for such scenarios in patch 2, see the "with -U1" test).

  - Should tests be added in a separate commit?  This is what I did as I
    thought it would help with readability, but...

Thanks in advance for taking a look!

Michał Kępień (2):
  diff: add -I<regex> that ignores matching changes
  t: add -I<regex> tests

 Documentation/diff-options.txt |   3 +
 diff.c                         |  16 ++
 diff.h                         |   2 +
 t/t4069-diff-ignore-regex.sh   | 330 +++++++++++++++++++++++++++++++++
 xdiff/xdiff.h                  |   2 +
 xdiff/xdiffi.c                 |  36 ++++
 6 files changed, 389 insertions(+)
 create mode 100755 t/t4069-diff-ignore-regex.sh

-- 
2.28.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux