Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save noahcampbell/234268 to your computer and use it in GitHub Desktop.
Save noahcampbell/234268 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
my $branch = shift;
my $head = `git rev-list --date-order --max-count=1 $branch`;
my $svnrev = `git svn find-rev $head`;
my $diff = `git diff --find-copies-harder --no-prefix $branch`;
my $space = " ";
chomp $svnrev;
my @lines = split /\n/, $diff;
for (my $i = 0; $i < scalar @lines; $i++) {
my $line = $lines[$i];
if ($line =~ m{^--- /dev/null.*}) {
my ($newfile) = $lines[$i + 1] =~ m{^\+\+\+ (.+)\s*$};
$line =~ s{/dev/null.*$}{$newfile$space(revision 0)};
print "$line\n";
next;
}
$line =~ s/^(--- .*)/$1$space(revision $svnrev)/;
$line =~ s/^(\+\+\+ .*)/$1$space(working copy)/;
print "$line\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment