X-Loop: help-debbugs@HIDDEN Subject: bug#23596: Add exclude directories feature Resent-From: <daveparrish@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-diffutils@HIDDEN Resent-Date: Sat, 21 May 2016 17:39:02 +0000 Resent-Message-ID: <handler.23596.B.146385229531526 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 23596 X-GNU-PR-Package: diffutils X-GNU-PR-Keywords: To: 23596 <at> debbugs.gnu.org X-Debbugs-Original-To: <bug-diffutils@HIDDEN> Received: via spool by submit <at> debbugs.gnu.org id=B.146385229531526 (code B ref -1); Sat, 21 May 2016 17:39:02 +0000 Received: (at submit) by debbugs.gnu.org; 21 May 2016 17:38:15 +0000 Received: from localhost ([127.0.0.1]:60125 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1b4Aqs-0008CN-T7 for submit <at> debbugs.gnu.org; Sat, 21 May 2016 13:38:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51743) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <daveparrish@HIDDEN>) id 1b47od-0003ph-Cl for submit <at> debbugs.gnu.org; Sat, 21 May 2016 10:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <daveparrish@HIDDEN>) id 1b47oT-0006f3-Fc for submit <at> debbugs.gnu.org; Sat, 21 May 2016 10:23:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <daveparrish@HIDDEN>) id 1b47oT-0006ek-CB for submit <at> debbugs.gnu.org; Sat, 21 May 2016 10:23:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <daveparrish@HIDDEN>) id 1b47oN-0001hT-JT for bug-diffutils@HIDDEN; Sat, 21 May 2016 10:23:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <daveparrish@HIDDEN>) id 1b47oI-0006cm-Ur for bug-diffutils@HIDDEN; Sat, 21 May 2016 10:23:27 -0400 Received: from w1.tutanota.de ([81.3.6.162]:60436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <daveparrish@HIDDEN>) id 1b47oI-0006cE-JQ for bug-diffutils@HIDDEN; Sat, 21 May 2016 10:23:22 -0400 Received: from localhost (unknown [127.0.0.1]) by w1.tutanota.de (Postfix) with ESMTP id 4CE0EFA8505 for <bug-diffutils@HIDDEN>; Sat, 21 May 2016 14:23:20 +0000 (UTC) Received: from w1.tutanota.de ([127.0.0.1]) by localhost (w1.tutanota.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id He_Df0V7c0Ni for <bug-diffutils@HIDDEN>; Sat, 21 May 2016 14:23:14 +0000 (UTC) Received: from w1.tutanota.de (unknown [127.0.0.1]) by w1.tutanota.de (Postfix) with ESMTP id 1C529FA8501 for <bug-diffutils@HIDDEN>; Sat, 21 May 2016 14:23:14 +0000 (UTC) Date: Sat, 21 May 2016 15:23:14 +0100 (BST) From: <daveparrish@HIDDEN> Message-ID: <KIIghJI--3-0@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_7698_1890366927.1463840594101" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Mailman-Approved-At: Sat, 21 May 2016 13:38:14 -0400 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.1 (----) ------=_Part_7698_1890366927.1463840594101 Content-Type: multipart/alternative; boundary="----=_Part_7699_495174991.1463840594101" ------=_Part_7699_495174991.1463840594101 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hello, I would like to add a feature to the diff utility. The feature would allow exclude patterns to match directories as well as base filenames so entire directories can easily be ignored. The feature adds the option `--exclude-directory` which is intended to be used with `--exclude=PAT` or `--exclude-from=FILE`. I've attached a patch file which adds this feature along with a couple of tests and documentation. Is this something that can be added to diff? David -- Securely sent with Tutanota. Claim your encrypted mailbox today! https://tutanota.com ------=_Part_7699_495174991.1463840594101 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> Hello,<div><br /></div><div>I would like to add a feature to the diff utility. The feature would allow exclude patterns to match directories as well as base filenames so entire directories can easily be ignored.</div><div><br /></div><div>The feature adds the option `--exclude-directory` which is intended to be used with `--exclude=PAT` or `--exclude-from=FILE`.</div><div><br /></div><div>I've attached a patch file which adds this feature along with a couple of tests and documentation.</div><div><span style="line-height: 1.5"><br /></span></div><div><span style="line-height: 1.5">Is this something that can be added to diff?</span></div><div><br /></div><div>David<br /> -- <br /> Securely sent with Tutanota. Claim your encrypted mailbox today! <br /> <a href="https://tutanota.com" target="_blank">https://tutanota.com</a></div> </body> </html> ------=_Part_7699_495174991.1463840594101-- ------=_Part_7698_1890366927.1463840594101 Content-Type: text/x-patch; charset=us-ascii; name=exclude-directory.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=exclude-directory.patch diff --git a/src/diff.c b/src/diff.c index 9bc1d96..4420623 100644 --- a/src/diff.c +++ b/src/diff.c @@ -122,6 +122,7 @@ enum NO_IGNORE_FILE_NAME_CASE_OPTION, NORMAL_OPTION, SDIFF_MERGE_ASSIST_OPTION, + EXCLUDE_DIRECTORY_OPTION, STRIP_TRAILING_CR_OPTION, SUPPRESS_BLANK_EMPTY_OPTION, SUPPRESS_COMMON_LINES_OPTION, @@ -208,6 +209,7 @@ static struct option const longopts[] = {"show-function-line", 1, 0, 'F'}, {"side-by-side", 0, 0, 'y'}, {"speed-large-files", 0, 0, 'H'}, + {"exclude-directory", 0, 0, EXCLUDE_DIRECTORY_OPTION}, {"starting-file", 1, 0, 'S'}, {"strip-trailing-cr", 0, 0, STRIP_TRAILING_CR_OPTION}, {"suppress-blank-empty", 0, 0, SUPPRESS_BLANK_EMPTY_OPTION}, @@ -592,6 +594,10 @@ main (int argc, char **argv) sdiff_merge_assist = true; break; + case EXCLUDE_DIRECTORY_OPTION: + exclude_directory = true; + break; + case STRIP_TRAILING_CR_OPTION: strip_trailing_cr = true; break; @@ -911,6 +917,7 @@ static char const * const option_help_msgid[] = { N_(" --no-ignore-file-name-case consider case when comparing file names"), N_("-x, --exclude=PAT exclude files that match PAT"), N_("-X, --exclude-from=FILE exclude files that match any pattern in FILE"), + N_(" --exclude-directory exclude directories matching exclude pattern"), N_("-S, --starting-file=FILE start with FILE when comparing directories"), N_(" --from-file=FILE1 compare FILE1 to all operands;\n" " FILE1 can be a directory"), diff --git a/src/diff.h b/src/diff.h index 0983e7c..413790a 100644 --- a/src/diff.h +++ b/src/diff.h @@ -224,6 +224,9 @@ XTERN bool speed_large_files; /* Patterns that match file names to be excluded. */ XTERN struct exclude *excluded; +/* Include directory as part of exclude matching. */ +XTERN bool exclude_directory; + /* Don't discard lines. This makes things slower (sometimes much slower) but will find a guaranteed minimal set of changes. */ XTERN bool minimal; diff --git a/src/dir.c b/src/dir.c index c8aa6a5..e9c70d6 100644 --- a/src/dir.c +++ b/src/dir.c @@ -96,8 +96,15 @@ dir_read (struct file_data const *dir, struct dirdata *dirdata) && (d_name[1] == 0 || (d_name[1] == '.' && d_name[2] == 0))) continue; - if (excluded_file_name (excluded, d_name)) - continue; + /* Exclude filename matches from diff */ + if (exclude_directory) { + if (excluded_file_name (excluded, + file_name_concat(dir->name, d_name, NULL))) + continue; + } else { + if (excluded_file_name (excluded, d_name)) + continue; + } while (data_alloc < data_used + d_size) { diff --git a/tests/exclude-directory b/tests/exclude-directory new file mode 100755 index 0000000..825154a --- /dev/null +++ b/tests/exclude-directory @@ -0,0 +1,48 @@ +#!/bin/sh +# exclude directory tests + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +TZ=UTC0 +export TZ + +fail=0 + +# Generate directory structure +mkdir a +mkdir b +echo ac > a/c +echo bc > b/c + +epoch='1970-01-01 00:00:00' +touch --date="$epoch" a b a/c b/c + +gen_exp_default() +{ + printf '%s' \ +"diff -r '--exclude=b/*' a/c b/c +1c1 +< ac +--- +> bc +" +} + +gen_exp_excluded() +{ + printf '%s' \ +"Only in a: c +" +} + +diff -r --exclude="b/*" a b > out +test $? = 1 || fail=1 +gen_exp_default > exp || framework_failure_ +compare exp out || fail=1 + +diff -r --exclude-directory --exclude="b/*" a b > out +test $? = 1 || fail=1 +gen_exp_excluded > exp || framework_failure_ +compare exp out || fail=1 + +Exit $fail ------=_Part_7698_1890366927.1463840594101--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: <daveparrish@HIDDEN> Subject: bug#23596: Acknowledgement (Add exclude directories feature) Message-ID: <handler.23596.B.146385229531526.ack <at> debbugs.gnu.org> References: <KIIghJI--3-0@HIDDEN> X-Gnu-PR-Message: ack 23596 X-Gnu-PR-Package: diffutils Reply-To: 23596 <at> debbugs.gnu.org Date: Sat, 21 May 2016 17:39:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-diffutils@HIDDEN If you wish to submit further information on this problem, please send it to 23596 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 23596: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D23596 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.