Created
February 4, 2011 22:03
-
-
Save mpusz/811864 to your computer and use it in GitHub Desktop.
Adds #ifdef compiler commands to all modified files in order to allow quick reversibility of the changes done between 2 provided GIT revisions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Made by Mateusz Pusz | |
# Please give feedback | |
# | |
# Script purpose is to add #ifdef compiler commands to all modified | |
# files in order to allow quick reversibility of the changes done | |
# between 2 provided GIT revisions. | |
# | |
use warnings; | |
use strict; | |
my $argNum = @ARGV; | |
if($argNum != 3) { | |
print "Usage: do_reverse.pl REV_START REV_FINISH LABEL\n\n"; | |
print " REV_START GIT revision with the old code to #ifdef\n"; | |
print " REV_FINISH GIT revision with the new code to #ifdef\n"; | |
print " LABEL ifdef label to use\n"; | |
exit(0); | |
} | |
my ( $rev1, $rev2, $label ) = @ARGV; | |
my @files = `git diff -w --name-status $rev1 $rev2`; | |
foreach ( @files ) { | |
# skip files that were not modifed | |
next if ($_ !~ /^M/); | |
my $file = (split)[1]; | |
my $file_rev1 = $file . ":" . $rev1; | |
my $file_rev2 = $file . ":" . $rev2; | |
`git show $rev1:$file > $file_rev1`; | |
`git show $rev2:$file > $file_rev2`; | |
`diff -w -D $label $file_rev1 $file_rev2 > $file`; | |
`rm $file_rev1`; | |
`rm $file_rev2`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment