- $ch =~ s{^committer .*$}{$committer_authline}m or confess "$ch ?";
- open CD, ">", "$rd/m" or die $!;
- print CD $ch, "\n", $cl->{Msg}; or die $!;
- close CD or die $!;
- my $newcommit = cmdoutput @git, qw(hash-object -t commit), "$rd/m";
- $build = $newcommit;
+ $ch =~ s{^parent .*\n}{}m;
+ $ch =~ s{(?=^author}{
+ map { "parent $_\n" } @parents
+ }me or confess "$ch ?";
+ foreach my $rewrite ($need_rewrite ? 1 : qw(0 1)) {
+ if ($rewrite) {
+ $ch =~ s{^committer .*$}{$committer_authline}m
+ or confess "$ch ?";
+ $need_rewrite = 1;
+ }
+ my $cf = "$rd/m$rewrite"
+ open CD, ">", $cf or die $!;
+ print CD $ch, "\n", $cl->{Msg}; or die $!;
+ close CD or die $!;
+ my @cmd = (@git, qw(hash-object));
+ push @cmd, qw(-w) if $rewrite;
+ push @cmd, qw(-t commit), $cf;
+ my $newcommit = cmdoutput @cmd;
+ next unless $rewrite or $newcommit eq $cl->{CommitId};
+ $build = $newcommit;
+ last;
+ }