How to efficiently find where a patch applies?

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

 



In the past couple weeks, I have had several occasions where a collaborator has
sent a patch, which does not have information about where the patch forked from
master.  I wrote the following scripts to try to discover where the patch
should be applied.  Is there a better way?

create_awk.pl:
----------------------->8------------------------------------------
#! /usr/bin/env perl
print <<HEADER;
BEGIN {
	i = 0
}
HEADER

print "/";

my $numseen=0;
my $nummatches = 0;
while(<STDIN>){
	if(/^index ([0-9a-f]+)\.\..+$/){
		$hash = $1;
	} else {
		next;
	}
	if($hash =~ /^0*$/) {
		next;
	}
	print "|" if($numseen > 0);
	$numseen = 1;
	++$nummatches;
	print "$hash";	
}
print "/{ i += 1; print \$0}\n";

print <<FOOTER;
END {
	if( i == $nummatches) {
		print "FOUND IT";
		exit 1;
	}
	print "i =",i;
	exit 0;
}
FOOTER
----------------------->8------------------------------------------

To find the place where the patch applies, I then would run something like

git rev-list --all | \
while read commit; do \
	git ls-tree -r $commit | \
	awk "$(perl ~/programs/git-hacks/create_awk.pl < <patch file>)" > /dev/null || \
	echo $commit; \
done

Nathan Panike
--
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]