summaryrefslogtreecommitdiffstats
path: root/freed-ora/tags/f27/4.15.9-300.fc27.gnu/remove-binary-diff.pl
blob: 56dfe574498c8252cf93e210fef6dc9015e113ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl -w
# A script to remove those terrible binary diffs from the patches which
# screw up everything and rain on my parade.

use strict;

my @args=@ARGV;
my @current_patch;
my $is_binary = 0;
my $cnt = 0;

while(my $row = <>) {
	# diff marks the start of a new file to check
	if ($row =~ /^diff -.*?(\S+)$/) {
		if (!$is_binary) {
			foreach my $line (@current_patch) {
				print $line;
			}
		}
		$is_binary = 0;
		@current_patch = ();
# Leave these alone, they do no harm. -lxoliva
#	} elsif ($row =~ /Binary files (.)* differ$/) {
#		$is_binary = 1;
	} elsif ($row =~ /GIT binary patch/) {
		$is_binary = 1;
	}
	push (@current_patch, $row);
}

if (!$is_binary) {
	foreach my $line (@current_patch) {
		print $line;
	}
}
OpenPOWER on IntegriCloud