From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id BF0141F4B4 for ; Thu, 1 Oct 2020 12:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732067AbgJAMpF convert rfc822-to-8bit (ORCPT ); Thu, 1 Oct 2020 08:45:05 -0400 Received: from mx.pao1.isc.org ([149.20.64.53]:18484 "EHLO mx.pao1.isc.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731891AbgJAMpD (ORCPT ); Thu, 1 Oct 2020 08:45:03 -0400 X-Greylist: delayed 2325 seconds by postgrey-1.27 at vger.kernel.org; Thu, 01 Oct 2020 08:45:02 EDT Received: from zmx1.isc.org (zmx1.isc.org [149.20.0.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.pao1.isc.org (Postfix) with ESMTPS id 739A83AB213 for ; Thu, 1 Oct 2020 12:06:16 +0000 (UTC) Received: from zmx1.isc.org (localhost [127.0.0.1]) by zmx1.isc.org (Postfix) with ESMTPS id 6A19F160047 for ; Thu, 1 Oct 2020 12:06:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zmx1.isc.org (Postfix) with ESMTP id 56E0F16007D for ; Thu, 1 Oct 2020 12:06:16 +0000 (UTC) Received: from zmx1.isc.org ([127.0.0.1]) by localhost (zmx1.isc.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Zg9dQ4t4lHc6 for ; Thu, 1 Oct 2020 12:06:16 +0000 (UTC) Received: from larwa.hq.kempniu.pl (unknown [212.180.223.213]) by zmx1.isc.org (Postfix) with ESMTPSA id B4EA2160047 for ; Thu, 1 Oct 2020 12:06:15 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: git@vger.kernel.org Subject: [PATCH 0/2] diff: add -I that ignores matching changes Date: Thu, 1 Oct 2020 14:06:04 +0200 Message-Id: <20201001120606.25773-1-michal@isc.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 that ignores matching changes t: add -I 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