523d987
#!/usr/bin/perl -w
523d987
# A script to remove those terrible binary diffs from the patches which
523d987
# screw up everything and rain on my parade.
523d987
523d987
use strict;
523d987
523d987
my @args=@ARGV;
523d987
my @current_patch;
523d987
my $is_binary = 0;
523d987
my $cnt = 0;
523d987
523d987
while(my $row = <>) {
523d987
	# diff marks the start of a new file to check
523d987
	if ($row =~ /^diff --git.*?(\S+)$/) {
523d987
		if (!$is_binary) {
523d987
			foreach my $line (@current_patch) {
523d987
				print $line;
523d987
			}
523d987
		}
523d987
		$is_binary = 0;
523d987
		@current_patch = ();
523d987
	} elsif ($row =~ /Binary files (.)* differ$/) {
523d987
		$is_binary = 1;
b9e51f8
	} elsif ($row =~ /GIT binary patch/) {
b9e51f8
		$is_binary = 1;
523d987
	}
523d987
	push (@current_patch, $row);
523d987
}
523d987
523d987
if (!$is_binary) {
523d987
	foreach my $line (@current_patch) {
523d987
		print $line;
523d987
	}
523d987
}