diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2017-08-25 11:26:31 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-06-16 12:25:49 +0100 |
commit | bcaec0456e20d69fd35784543c6d80401f4d6754 (patch) | |
tree | 6dc3ae9b76cc76b335018dfd301910e75291f730 /git-debrebase | |
parent | 5f5a11b1abc80453bd91268e859a41757f02313a (diff) |
git-debrebase: downstream-rebase-launder-v0 first cut
Diffstat (limited to 'git-debrebase')
-rwxr-xr-x | git-debrebase | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/git-debrebase b/git-debrebase index a1d277e..c3ff3af 100755 --- a/git-debrebase +++ b/git-debrebase @@ -716,6 +716,51 @@ sub cmd_analyse () { STDOUT->error and die $!; } +sub cmd_downstream_rebase_launder_v0 () { + badusage "needs 1 argument, the baseline" unless @ARGV=0; + my ($base) = @ARGV; + $base = git_rev_parse $base; + my $old_head = get_head(); + my $current = $old_head; + my $topmost_keep; + for (;;) { + if ($current eq $base) { + $topmust_keep //= $current; + print "$current BASE: stopping\n"; + last; + } + my $cl = classify $current; + print " $current $cl->{Type}"; + my $keep = 0; + my $p0 = $cl->{Parents}[0]{CommitId}; + if ($cl->{Type} eq 'Pseudomerge') { + $current = $cl->{Contributor}{CommitId}; + print " ^".($cl->{Contributor}{Ix}+1); + } elsif ($cl->{Type} eq 'AddPatches' or + $cl->{Type} eq 'Changelog') { + print " strip"; + $current = $p0; + } else { + print " keep"; + $current = $p0; + $keep = 1; + } + print "\n"; + if ($keep) { + $topmost_keep //= $current; + } else { + die "to-be stripped changes not on top of the branch\n" + if $topmost_unstripped; + } + } + if ($topmost_keep eq $old_head) { + print "unchanged\n"; + } else { + print "updating to $topmost_keep\n"; + update_head $old_head, $topmost_keep, 'downstream-rebase-launder-v0'; + } +} + GetOptions("D+" => \$debuglevel) or die badusage "bad options\n"; initdebug('git-debrebase '); enabledebug if $debuglevel; |