[PATCH 4/5] add--interactive: allow negatation of hunk filters

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

 



This patch lets you filter out certain boring hunks, rather
than trying to match particular interesting ones (which may
be much easier, depending on your file contents).

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 git-add--interactive.perl |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index bb16f71..917b2a9 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -87,6 +87,7 @@ sub colored {
 my $patch_mode;
 my $patch_mode_revision;
 my @patch_mode_hunk_filter;
+my $patch_mode_negate_filter;
 
 sub apply_patch;
 sub apply_patch_for_checkout_commit;
@@ -1279,9 +1280,9 @@ sub want_hunk {
 	my $text = join('', @{$hunk->{TEXT}});
 
 	foreach my $re (@patch_mode_hunk_filter) {
-		return 1 if $text =~ $re;
+		return !$patch_mode_negate_filter if $text =~ $re;
 	}
-	return 0;
+	return $patch_mode_negate_filter;
 }
 
 sub patch_update_file {
@@ -1590,6 +1591,9 @@ sub process_args {
 				or die "malformed hunk filter $1: " . trim_error($@);
 			push @patch_mode_hunk_filter, $re;
 		}
+		elsif ($ARGV[0] eq '--negate-hunk-filter') {
+			$patch_mode_negate_filter = 1;
+		}
 		else {
 			last;
 		}
-- 
1.7.5.4.31.ge4d5e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]