memoize('cfg');
+sub dd ($) {
+ my ($v) = @_;
+ my $dd = new Data::Dumper [ $v ];
+ Terse $dd 1; Indent $dd 0; Useqq $dd 1;
+ return Dump $dd;
+}
+
sub get_commit ($) {
my ($objid) = @_;
my $data = git_cat_file $objid, 'commit';
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
my ($type, @rest) = @_;
$r = { %$r, Type => $type, @rest };
if ($debuglevel) {
- my $dd = new Data::Dumper [ $r ];
- Terse $dd 1; Indent $dd 0; Useqq $dd 1;
- printdebug " = $type ".(Dump $dd)."\n";
+ printdebug " = $type ".(dd $r)."\n";
}
return $r;
};
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;
my ($n, @x) = @_; # may be ''
my $pc = $pieces{$n} //= {
Name => $n,
- Desc => ($n ? "upstream piece $n" : "upstream (main piece"),
+ Desc => ($n ? "upstream piece \`$n'" : "upstream (main piece"),
};
while (my $k = shift @x) { $pc->{$k} = shift @x; }
+ $pc;
};
my @newpieces;
foreach my $pc (values %pieces) {
if (!$pc->{Old}) {
- $problem->("introducing upstream piece $pc->{Name}");
+ $problem->("introducing upstream piece \`$pc->{Name}'");
} elsif (!$pc->{New}) {
- $problem->("dropping upstream piece $pc->{Name}");
+ $problem->("dropping upstream piece \`$pc->{Name}'");
} elsif (!is_fast_fwd $pc->{Old}, $pc->{New}) {
$problem->("not fast forward: $pc->{Name} $pc->{Old}..$pc->{New}");
}
}
+ printdebug "%pieces = ", (dd \%pieces), "\n";
+ printdebug "\@newpieces = ", (dd \@newpieces), "\n";
+
if ($problems) {
if ($opt_force) {
printf STDERR
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 @git;
+ $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;
+ die $! unless $!==ENOTEMPTY;
unlink "debian/changelog" or die $!;
open CN, ">", "debian/changelog" or die $!;
my $oldclog = git_cat_file ":debian/changelog";
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 @git;
+ $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