# git-debrebase new-upstreams-v0 \
# NEW-VERSION ORIG-COMMITISH
# [EXTRA-ORIG-NAME EXTRA-ORIG-COMMITISH ...]
+# [<git-rebase options>]
# usages:
# git-debrebase status
update_head $old, $new, $mrest;
}
+sub update_head_postlaunder ($$$) {
+ my ($old, $tip, $reflogmsg) = @_;
+ update_head $old, $tip, $reflogmsg;
+ # no tree changes except debian/patches
+ runcmd @git, qw(rm --quiet --ignore-unmatch -rf debian/patches);
+}
+
sub cmd_launder () {
badusage "no arguments to launder allowed" if @ARGV;
my $old = get_head();
my ($tip,$breakwater,$last_upstream_merge) = walk $old;
- update_head $old, $tip, 'launder';
- # no tree changes except debian/patches
- runcmd @git, qw(rm --quiet --ignore-unmatch -rf debian/patches);
+ update_head_postlaunder $old, $tip, 'launder';
printf "# breakwater tip\n%s\n", $breakwater;
printf "# working tip\n%s\n", $tip;
printf "# last upstream merge\n%s\n", $last_upstream_merge;
}
sub cmd_new_upstream_v0 () {
- # xxx would like to support more git-rebase options
- badusage
- "need NEW-VERSION UPS-COMMITISH [EXTRA-UPS-NAME EXTRA-UPS-COMMITISH...]"
- unless @ARGV % 2 == 0 and @ARGV >= 2;
# tree should be clean and this is not checked
# automatically and unconditionally launders before rebasing
# if rebase --abort is used, laundering has still been done
my %pieces;
+ badusage "need NEW-VERSION UPS-COMMITTISH" unless @ARGV >= 2;
+
# parse args - low commitment
my $new_version = (new Dpkg::Version scalar(shift @ARGV), check => 1);
my $new_upstream_version = $new_version->version();
OldIx => 0,
New => $new_upstream,
);
- while (@ARGV) {
+ while (@ARGV && $ARGV[0] !~ m{^-}) {
my $n = shift @ARGV;
+
+ badusage "for each EXTRA-UPS-NAME need EXTRA-UPS-COMMITISH"
+ unless @ARGV && $ARGV[0] !~ m{^-};
+
my $c = git_rev_parse shift @ARGV;
die unless $n =~ m/^$extra_orig_namepart_re$/;
$newpiece->($n, New => $c);
if (@newpieces > 1) {
# need to make the upstream subtree merge commit
- my $us_tree = cmdoutput @git, qw(write-tree);
- my @cmd = (@git, qw(commit-tree), $us_tree);
- push @cmd, qw(-p), $_ foreach @upstream_merge_parents;
- push @cmd, qw(-m), "Combine upstreams for $new_upstream_version";
- push @cmd, qw(-m),
- "[git-debrebase new-upstream combine . ".
- (join " ", map { $_->{Name} } @newpieces[1..$#newpieces]).
- "]";
- $new_upstream = cmdoutput @cmd;
+ $new_upstream = make_commit \@upstream_merge_parents,
+ [ "Combine upstreams for $new_upstream_version",
+ ("[git-debrebase new-upstream combine . ".
+ (join " ", map { $_->{Name} } @newpieces[1..$#newpieces]).
+ "]"),
+ ];
}
# $new_upstream is either the single upstream commit, or the
# Now we have to add a changelog stanza so the Debian version
# is right.
-
die if unlink "debian";
- die $! unless $!==ENOTEMPTY;
- unlink "debian/changelog" or die $!;
+ die $! unless $!==ENOENT or $!==ENOTEMPTY;
+ unlink "debian/changelog" or $!==ENOENT or die $!;
+ mkdir "debian" or die $!;
open CN, ">", "debian/changelog" or die $!;
my $oldclog = git_cat_file ":debian/changelog";
$oldclog =~ m/^($package_re) \(\S+\) / or
# the laundering output, because git-rebase can't easily be made
# to make a replay list which is based on some other branch
- update_head $old_head, $old_laundered_tip, 'launder for new upstream';
+ update_head_postlaunder $old_head, $old_laundered_tip,
+ 'launder for new upstream';
- my @cmd = (@git, qw(rebase --onto), $new_bw, $old_bw);
+ my @cmd = (@git, qw(rebase --onto), $new_bw, $old_bw, @ARGV);
runcmd @cmd;
# now it's for the user to sort out
}