X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=git-debrebase;h=eb0acb21c0ab0df27204c1afdd04437ad8d83835;hp=13ca472d47881b34361a8c4dc160bc0113d0f47c;hb=5026d3c30a7046299179ca3ba422fb21505cdf4d;hpb=cd06cd0cf3b1190fde3862684a18a1d7d56a834e diff --git a/git-debrebase b/git-debrebase index 13ca472d..eb0acb21 100755 --- a/git-debrebase +++ b/git-debrebase @@ -36,6 +36,18 @@ use Dpkg::Version; use File::FnMatch qw(:fnmatch); use File::Copy; +our ($usage_message) = <<'END'; +usages: + git-debrebase [] [--|-i ] + git-debrebase [] status + git-debrebase [] prepush [--prose=...] + git-debrebase [] quick|conclude + git-debrebase [] new-upstream [
] + git-debrebase [] convert-from-gbp [] + ... +See git-debrebase(1), git-debrebase(5), dgit-maint-debrebase(7) (in dgit). +END + our ($opt_force, $opt_noop_ok, @opt_anchors); our ($opt_defaultcmd_interactive); @@ -49,11 +61,15 @@ sub badusage ($) { finish 8; } -sub getoptions { +sub getoptions_main { my $m = shift; local $SIG{__WARN__}; # GetOptions calls `warn' to print messages GetOptions @_ or badusage $m; } +sub getoptions { + my $sc = shift; + getoptions_main "bad options follow \`git-debrebase $sc'", @_; +} sub cfg ($;$) { my ($k, $optional) = @_; @@ -579,6 +595,7 @@ sub keycommits ($;$$$$) { my ($anchor, $breakwater); my $clogonly; my $cl; + my $found_pm; $fatal //= sub { fail $_[1]; }; my $x = sub { my ($cb, $tagsfx, $mainwhy, $xwhy) = @_; @@ -618,12 +635,20 @@ sub keycommits ($;$$$$) { $breakwater = undef; } elsif ($ty eq 'Pseudomerge' or $ty eq 'AddPatches') { + my $found_pm = 1; $x->($furniture, (lc $ty), "found interchange bureaucracy commit ($ty)"," ($head)"); } elsif ($ty eq 'DgitImportUnpatched') { - $x->($trouble, 'dgitimport', - "found dgit dsc import ($head)"); - return (undef,undef); + if ($found_pm) { + $x->($trouble, 'dgitimport', + "found dgit dsc import"," ($head)"); + return (undef,undef); + } else { + $x->($fatal, 'unprocessable', + "found bare dgit dsc import with no prior history", + " ($head)"); + return (undef,undef); + } } else { $x->($fatal, 'unprocessable', "found unprocessable commit, cannot cope: $cl->{Why}", @@ -685,8 +710,8 @@ sub walk ($;$$) { if ($nogenerate) { return (undef,undef); } - fail "found unprocessable commit, cannot cope:". - (defined $cl->{Why} ? "; $cl->{Why}": ''). + fail "found unprocessable commit, cannot cope". + (defined $cl->{Why} ? "; $cl->{Why}:": ':'). " (commit $cur) (d.". (join ' ', map { sprintf "%#x", $_->{Differs} } @{ $cl->{Parents} }). @@ -798,13 +823,12 @@ sub walk ($;$$) { next; } else { # Everything is from this import. This kind of import - # is already in valid breakwater format, with the - # patches as commits. - printf $report " NoPM" if $report; - # last thing we processed will have been the first patch, - # if there is one; which is fine, so no need to rewrite - # on account of this import - $build_start->("ImportOrigin", $cur); + # is already nearly in valid breakwater format, with the + # patches as commits. Unfortunately it contains + # debian/patches/. + printdebug "*** WALK BOMB bare dgit import\n"; + $cl->{Why} = "bare dgit dsc import"; + return $bomb->(); } die "$ty ?"; } else { @@ -1168,21 +1192,23 @@ sub do_stitch ($;$) { stitch($dangling_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose); } -sub resolve_upstream_version ($$) { - my ($new_upstream, $version) = @_; +sub upstream_commitish_search ($$) { + my ($upstream_version, $tried) = @_; + # todo: at some point maybe use git-deborig to do this + foreach my $tagpfx ('', 'v', 'upstream/') { + my $tag = $tagpfx.(dep14_version_mangle $upstream_version); + my $new_upstream = git_get_ref "refs/tags/$tag"; + push @$tried, $tag; + return $new_upstream if length $new_upstream; + } +} - my $new_upstream_version = "$version"; - $new_upstream_version =~ s/-.*?$//;; +sub resolve_upstream_version ($$) { + my ($new_upstream, $upstream_version) = @_; if (!defined $new_upstream) { my @tried; - # todo: at some point maybe use git-deborig to do this - foreach my $tagpfx ('', 'v', 'upstream/') { - my $tag = $tagpfx.(dep14_version_mangle $new_upstream_version); - $new_upstream = git_get_ref "refs/tags/$tag"; - last if length $new_upstream; - push @tried, $tag; - } + $new_upstream = upstream_commitish_search $upstream_version, \@tried; if (!length $new_upstream) { fail "Could not determine appropriate upstream commitish.\n". " (Tried these tags: @tried)\n". @@ -1191,7 +1217,7 @@ sub resolve_upstream_version ($$) { } $new_upstream = git_rev_parse $new_upstream; - return ($new_upstream, $new_upstream_version); + return $new_upstream; } sub cmd_new_upstream () { @@ -1211,9 +1237,9 @@ sub cmd_new_upstream () { } my $new_upstream = shift @ARGV; - my $new_upstream_version; - ($new_upstream, $new_upstream_version) = - resolve_upstream_version $new_upstream, $new_version; + my $new_upstream_version = upstreamversion $new_version; + $new_upstream = + resolve_upstream_version $new_upstream, $new_upstream_version; record_ffq_auto(); @@ -1524,7 +1550,7 @@ sub cmd_status () { sub cmd_stitch () { my $prose = 'stitch'; - getoptions("bad options follow \`git-debrebase stitch'", + getoptions("stitch", 'prose=s', \$prose); badusage "no arguments allowed" if @ARGV; do_stitch $prose, 0; @@ -1588,7 +1614,7 @@ sub make_patches ($) { sub cmd_make_patches () { my $opt_quiet_would_amend; - getoptions("bad options follow \`git-debrebase make-patches'", + getoptions("make-patches", 'quiet-would-amend!', \$opt_quiet_would_amend); badusage "no arguments allowed" if @ARGV; my $old_head = get_head(); @@ -1620,8 +1646,9 @@ sub cmd_convert_from_gbp () { my ($upstream_spec) = @ARGV; - my ($upstream, $upstream_version) = - resolve_upstream_version($upstream_spec, $version); + my $upstream_version = upstreamversion $version; + my $upstream = + resolve_upstream_version($upstream_spec, $upstream_version); my $old_head = get_head(); @@ -1809,7 +1836,8 @@ sub cmd_downstream_rebase_launder_v0 () { } } -getoptions("bad options\n", +getoptions_main + ("bad options\n", "D+" => \$debuglevel, 'noop-ok', => \$opt_noop_ok, 'f=s' => \@snag_force_opts, @@ -1826,7 +1854,9 @@ getoptions("bad options\n", # approach. '-i=s{0,}' does not work with bundling. push @$opt_defaultcmd_interactive, @ARGV; @ARGV=(); - }); + }, + 'help' => sub { print $usage_message or die $!; finish 0; }, + ); initdebug('git-debrebase '); enabledebug if $debuglevel;