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