X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=git-debrebase;h=2687ef1f6873240c22feb16df93621328841c809;hb=c83cc428208bee99de3b75158b9779449403ee1b;hp=07e5f478cac58281570da99ef27e57953c0a6a53;hpb=3028f34f1868b3726f856ede688437b5279c2b05;p=dgit.git diff --git a/git-debrebase b/git-debrebase index 07e5f478..2687ef1f 100755 --- a/git-debrebase +++ b/git-debrebase @@ -573,7 +573,7 @@ sub keycommits ($;$$$$) { my ($anchor, $breakwater); my $clogonly; my $cl; - $fatal //= sub { fail $_[2]; }; + $fatal //= sub { fail $_[1]; }; my $x = sub { my ($cb, $tagsfx, $mainwhy, $xwhy) = @_; my $why = $mainwhy.$xwhy; @@ -679,10 +679,11 @@ sub walk ($;$$) { if ($nogenerate) { return (undef,undef); } - die "commit $cur: Cannot cope with this commit (d.". + fail "found unprocessable commit, cannot cope:". + (defined $cl->{Why} ? "; $cl->{Why}": ''). + " (commit $cur) (d.". (join ' ', map { sprintf "%#x", $_->{Differs} } @{ $cl->{Parents} }). - (defined $cl->{Why} ? "; $cl->{Why}": ''). ")"; }; @@ -1161,23 +1162,12 @@ sub do_stitch ($;$) { stitch($dangling_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose); } -sub cmd_new_upstream () { - # automatically and unconditionally launders before rebasing - # if rebase --abort is used, laundering has still been done - - my %pieces; +sub resolve_upstream_version ($$) { + my ($new_upstream, $version) = @_; - badusage "need NEW-VERSION [UPS-COMMITTISH]" unless @ARGV >= 1; - - # parse args - low commitment - my $spec_version = shift @ARGV; - my $new_version = (new Dpkg::Version $spec_version, check => 1); - if ($new_version->is_native()) { - $new_version = (new Dpkg::Version "$spec_version-1", check => 1); - } - my $new_upstream_version = $new_version->version(); + my $new_upstream_version = "$version"; + $new_upstream_version =~ s/-.*?$//;; - my $new_upstream = shift @ARGV; if (!defined $new_upstream) { my @tried; # todo: at some point maybe use git-deborig to do this @@ -1195,6 +1185,30 @@ sub cmd_new_upstream () { } $new_upstream = git_rev_parse $new_upstream; + return ($new_upstream, $new_upstream_version); +} + +sub cmd_new_upstream () { + # 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 >= 1; + + # parse args - low commitment + my $spec_version = shift @ARGV; + my $new_version = (new Dpkg::Version $spec_version, check => 1); + fail "bad version number \`$spec_version'" unless defined $new_version; + if ($new_version->is_native()) { + $new_version = (new Dpkg::Version "$spec_version-1", check => 1); + } + + my $new_upstream = shift @ARGV; + my $new_upstream_version; + ($new_upstream, $new_upstream_version) = + resolve_upstream_version $new_upstream, $new_version; + record_ffq_auto(); my $piece = sub { @@ -1590,11 +1604,18 @@ sub cmd_make_patches () { } sub cmd_convert_from_gbp () { - badusage "needs 1 optional argument, the upstream git rev" + badusage "want only 1 optional argument, the upstream git commitish" unless @ARGV<=1; + + my $clogp = parsechangelog(); + my $version = $clogp->{'Version'} + // die "missing Version from changelog"; + my ($upstream_spec) = @ARGV; - $upstream_spec //= 'refs/heads/upstream'; - my $upstream = git_rev_parse $upstream_spec; + + my ($upstream, $upstream_version) = + resolve_upstream_version($upstream_spec, $version); + my $old_head = get_head(); my $upsdiff = get_differs $upstream, $old_head;