390
"If these changes depend on each other, re-running ",
391
"without --no-rebase will be required."
392
}
393
- foreach my $d (@$linear_refs) {
393
+ while (1) {
394
+ my $d = shift @$linear_refs or last;
395
unless (defined $last_rev) {
396
(undef, $last_rev, undef) = cmt_metadata("$d~1");
397
unless (defined $last_rev) {
424
425
# we always want to rebase against the current HEAD,
426
# not any head that was passed to us
426
- my @diff = command('diff-tree', 'HEAD',
427
+ my @diff = command('diff-tree', $d,
428
$gs->refname, '--');
429
my @finish;
430
if (@diff) {
431
@finish = rebase_cmd();
431
- print STDERR "W: HEAD and ", $gs->refname,
432
+ print STDERR "W: $d and ", $gs->refname,
433
" differ, using @finish:\n",
433
- "@diff";
434
+ join("\n", @diff), "\n";
435
} else {
436
print "No changes between current HEAD and ",
437
$gs->refname,
440
@finish = qw/reset --mixed/;
441
}
442
command_noisy(@finish, $gs->refname);
443
+ if (@diff) {
444
+ @refs = ();
445
+ my ($url_, $rev_, $uuid_, $gs_) =
446
+ working_head_info($head, \@refs);
447
+ my ($linear_refs_, $parents_) =
448
+ linearize_history($gs_, \@refs);
449
+ if (scalar(@$linear_refs) !=
450
+ scalar(@$linear_refs_)) {
451
+ fatal "# of revisions changed ",
452
+ "\nbefore:\n",
453
+ join("\n", @$linear_refs),
454
+ "\n\nafter:\n",
455
+ join("\n", @$linear_refs_), "\n",
456
+ 'If you are attempting to commit ',
457
+ "merges, try running:\n\t",
458
+ 'git rebase --interactive',
459
+ '--preserve-merges ',
460
+ $gs->refname,
461
+ "\nBefore dcommitting";
462
+ }
463
+ if ($url_ ne $url) {
464
+ fatal "URL mismatch after rebase: ",
465
+ "$url_ != $url";
466
+ }
467
+ if ($uuid_ ne $uuid) {
468
+ fatal "uuid mismatch after rebase: ",
469
+ "$uuid_ != $uuid";
470
+ }
471
+ # remap parents
472
+ my (%p, @l, $i);
473
+ for ($i = 0; $i < scalar @$linear_refs; $i++) {
474
+ my $new = $linear_refs_->[$i] or next;
475
+ $p{$new} =
476
+ $parents->{$linear_refs->[$i]};
477
+ push @l, $new;
478
+ }
479
+ $parents = \%p;
480
+ $linear_refs = \@l;
481
+ }
482
$last_rev = $cmt_rev;
483
}
484
}