runcmd @git, qw(read-tree), "--prefix=$subdir/", $new_tree_object;
}
+sub make_commit ($$) {
+ my ($parents, $message_paras) = @_;
+ my $tree = cmdoutput @git, qw(write-tree);
+ my @cmd = (@git, qw(commit-tree), $tree);
+ push @cmd, qw(-p), $_ foreach @$parents;
+ push @cmd, qw(-m), $_ foreach @$message_paras;
+ return cmdoutput @cmd;
+}
+
# classify returns an info hash like this
# CommitId => $objid
# Hdr => # commit headers, including 1 final newline
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;
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
read_tree_subdir 'debian', "$old_bw:debian";
# index now contains the breakwater merge contents
-
- my $bw_tree = cmdoutput @git, qw(write-tree);
- my @cmd = (@git, qw(commit-tree), $bw_tree);
- push @cmd, qw(-p), $old_bw, qw(-p), $new_upstream;
- push @cmd, qw(-m), "Update to upstream $new_upstream_version";
- push @cmd, qw(-m),
- "[git-debrebase new-upstream breakwater $new_upstream_version]";
- $new_bw = cmdoutput @cmd;
+ $new_bw = make_commit [ $old_bw, $new_upstream ],
+ [ "Update to upstream $new_upstream_version",
+ "[git-debrebase new-upstream breakwater $new_upstream_version]",
+ ];
# 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 $!;
runcmd @git, qw(update-index --add --replace), 'debian/changelog';
# Now we have the final new breakwater branch in the index
-
- $bw_tree = cmdoutput @git, qw(write-tree);
- @cmd = (@git, qw(commit-tree), $bw_tree);
- push @cmd, qw(-p), $new_bw;
- push @cmd, qw(-m),
- "Update changelog for new upstream $new_upstream_version";
- push @cmd, qw(-m),
- "[git-debrebase new-upstream changelog $new_upstream_version]";
- $new_bw = cmdoutput @cmd;
+ $new_bw = make_commit [ $new_bw ],
+ [ "Update changelog for new upstream $new_upstream_version",
+ "[git-debrebase new-upstream changelog $new_upstream_version]",
+ ];
};
# we have constructed the new breakwater. we now need to commit to