Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 59 lines (49 sloc) 1.741 kB
#!/usr/bin/env perl
use strict;
use warnings;
use Cwd qw(realpath);
use File::Basename;
my $BASE_DIR = dirname realpath __FILE__;
chomp (my $GIT_DIR = `git rev-parse --git-dir`);
my $simplified_merges = do "$BASE_DIR/cache/simplified-merges.pl";
{
my @merges = `git log --all --merges --pretty=format:'%H %P'`;
my %altered;
my %merges;
for my $merge ( reverse @merges ) {
chomp $merge;
my ($commit, @parents) = split / /, $merge;
my $f;
$merges{$commit} = \@parents;
PARENT: for my $p ( 0 .. 1 ) {
my $parent = $parents[ $p ];
my $check_ancest = $parents[ 1 - $p ];
my $ancest = $merges{ $check_ancest } || next;
ANCEST: for my $c ( 0 .. 1 ) {
if ($parent eq $ancest->[ $c ]) {
$altered{$commit}++;
$parents[1 - $p] = $ancest->[1 - $c];
delete $merges{ $check_ancest };
delete $altered{ $check_ancest };
last PARENT;
}
}
}
}
my $regex = '(?:' . (join '|', keys %altered) . ')';
system "perl -i -pe's/^($regex )/# \$1/' $GIT_DIR/info/grafts";
open my $fh, '>>', "$GIT_DIR/info/grafts";
print { $fh } "# Redundant merges\n";
for my $commit ( keys %altered ) {
print { $fh } join(q{ }, $commit, @{ $merges{$commit} }) . "\n";
}
close $fh;
use Data::Dumper;
$Data::Dumper::Indent = 1;
$Data::Dumper::Terse = 1;
$Data::Dumper::Sortkeys = 1;
@altered{ keys %$simplified_merges } = values %$simplified_merges;
open $fh, '>', "$BASE_DIR/cache/simplified-merges.pl";
print { $fh } Dumper(\%altered);
close $fh;
}
Jump to Line
Something went wrong with that request. Please try again.