X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=git-debrebase;h=7d5d5bdd72254bc0dcbac180037d0355095d58cb;hb=297ff51a0df2098ea9fe088e229bcd1318bfe466;hp=00d2f575a6d29361fdc7ddf397f0e1a9be7348db;hpb=38d74ac90781b75e2239440c6430db00d909164a;p=dgit.git diff --git a/git-debrebase b/git-debrebase index 00d2f575..7d5d5bdd 100755 --- a/git-debrebase +++ b/git-debrebase @@ -99,12 +99,18 @@ sub fresh_workarea () { in_workarea sub { playtree_setup }; } +our $snags_forced; +our $snags_tripped; +our $snags_checked; our @deferred_updates; our @deferred_update_messages; sub run_deferred_updates ($) { my ($mrest) = @_; + confess 'dangerous internal error' if + !$snags_checked || $snags_tripped || $snags_forced; + my @upd_cmd = (@git, qw(update-ref --stdin -m), "debrebase: $mrest"); debugcmd '>|', @upd_cmd; open U, "|-", @upd_cmd or die $!; @@ -227,8 +233,6 @@ sub make_commit ($$) { } our @snag_force_opts; -our $snags_forced; -our $snags_tripped; sub snag ($$) { my ($tag,$msg) = @_; if (grep { $_ eq $tag } @snag_force_opts) { @@ -241,16 +245,19 @@ sub snag ($$) { } sub snags_maybe_bail () { + $snags_checked++; if ($snags_forced) { printf STDERR "%s: snags: %d overriden by individual -f options\n", $us, $snags_forced; + $snags_forced=0; } if ($snags_tripped) { if ($opt_force) { printf STDERR "%s: snags: %d overriden by global --force\n", $us, $snags_tripped; + $snags_tripped=0; } else { fail sprintf "%s: snags: %d blockers (you could -f, or --force)", @@ -560,7 +567,7 @@ sub keycommits ($;$$$) { $breakwater = undef; } elsif ($ty eq 'Mixed') { $x->($unclean, 'mixed', - 'found mixed upstream/packaging commit ($head)'); + "found mixed upstream/packaging commit ($head)"); $clogonly = undef; $breakwater = undef; } elsif ($ty eq 'Pseudomerge' or @@ -901,6 +908,7 @@ sub do_launder_head ($) { my $old = get_head(); record_ffq_auto(); my ($tip,$breakwater) = walk $old; + snags_maybe_bail(); update_head_postlaunder $old, $tip, $reflogmsg; return ($tip,$breakwater); } @@ -1083,8 +1091,8 @@ sub stitch ($$$$$) { update_head $old_head, $new_head, "stitch: $prose"; } -sub do_stitch ($) { - my ($prose) = @_; +sub do_stitch ($;$) { + my ($prose, $unclean) = @_; my ($ffq_prev, $gdrlast, $ffq_prev_commitish) = ffq_prev_info(); if (!$ffq_prev_commitish) { @@ -1093,7 +1101,8 @@ sub do_stitch ($) { } my $dangling_head = get_head(); - keycommits $dangling_head, \&snag, \&snag, \&snag; + keycommits $dangling_head, $unclean,$unclean,$unclean; + snags_maybe_bail(); stitch($dangling_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose); } @@ -1316,8 +1325,9 @@ sub cmd_stitch () { my $prose = 'stitch'; GetOptions('prose=s', \$prose) or die badusage("bad options to stitch"); badusage "no arguments allowed" if @ARGV; - do_stitch($prose); + do_stitch $prose, 0; } +sub cmd_prepush () { cmd_stitch(); } sub cmd_quick () { badusage "no arguments allowed" if @ARGV; @@ -1325,6 +1335,33 @@ sub cmd_quick () { do_stitch 'quick'; } +sub cmd_conclude () { + my ($ffq_prev, $gdrlast, $ffq_prev_commitish) = ffq_prev_info(); + if (!$ffq_prev_commitish) { + fail "No ongoing git-debrebase session." unless $opt_noop_ok; + return; + } + my $dangling_head = get_head(); + + badusage "no arguments allowed" if @ARGV; + do_launder_head 'launder for git-debrebase quick'; + do_stitch 'quick'; +} + +sub make_patches_staged ($) { + my ($head) = @_; + # Produces the patches that would result from $head if it were + # laundered. + my ($secret_head, $secret_bw, $last_anchor) = walk $head; + fresh_workarea(); + in_workarea sub { + runcmd @git, qw(checkout -q -b bw), $secret_bw; + runcmd @git, qw(checkout -q -b patch-queue/bw), $secret_head; + runcmd qw(gbp pq export); + runcmd @git, qw(add debian/patches); + }; +} + sub cmd_convert_from_gbp () { badusage "needs 1 optional argument, the upstream git rev" unless @ARGV<=1; @@ -1398,14 +1435,10 @@ sub cmd_convert_to_gbp () { badusage "no arguments allowed" if @ARGV; my $head = get_head(); my (undef, undef, undef, $ffq, $gdrlast) = ffq_prev_branchinfo(); - my ($anchor, $bw) = keycommits $head, 0; - fresh_workarea(); + keycommits $head, 0; my $out; + make_patches_staged $head; in_workarea sub { - runcmd @git, qw(checkout -q -b bw), $bw; - runcmd @git, qw(checkout -q -b patch-queue/bw), $head; - runcmd qw(gbp pq export); - runcmd @git, qw(add debian/patches); $out = make_commit ['HEAD'], [ 'Commit patch queue (converted from git-debrebase format)', '[git-debrebase convert-to-gbp: commit patches]', @@ -1415,6 +1448,7 @@ sub cmd_convert_to_gbp () { push @deferred_updates, "delete $ffq"; push @deferred_updates, "delete $gdrlast"; } + snags_maybe_bail(); update_head_checkout $head, $out, "convert to gbp (v0)"; print <