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;
};
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
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