X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=git-debrebase;h=171324671faed440b06338d41208b3eeda52e47b;hp=4667e8b1b8b408b8245e634f597adca7e78a12f3;hb=5ccc45c714e700c97d52fa291daef03cd2492780;hpb=b5cd66f2a318d196e4497bd428567826f5c2b5d6 diff --git a/git-debrebase b/git-debrebase index 4667e8b1..17132467 100755 --- a/git-debrebase +++ b/git-debrebase @@ -917,7 +917,7 @@ sub cmd_analyse () { } sub ffq_prev_branchinfo () { - # => ('status', "message", [$current, $ffq_prev, $drlast]) + # => ('status', "message", [$current, $ffq_prev, $gdrlast]) # 'status' may be # branch message is undef # weird-symref } no $current, @@ -927,9 +927,9 @@ sub ffq_prev_branchinfo () { return ('weird-symref', 'HEAD symref is not to refs/') unless $current =~ m{^refs/}; my $ffq_prev = "refs/$ffq_refprefix/$'"; - my $drlast = "refs/$gdrlast_refprefix/$'"; + my $gdrlast = "refs/$gdrlast_refprefix/$'"; printdebug "ffq_prev_branchinfo branch current $current\n"; - return ('branch', undef, $current, $ffq_prev, $drlast); + return ('branch', undef, $current, $ffq_prev, $gdrlast); } sub record_ffq_prev_deferred () { @@ -944,7 +944,7 @@ sub record_ffq_prev_deferred () { # if "deferred", will have added something about that to # @deferred_update_messages, and also maybe printed (already) # some messages about ff checks - my ($status, $message, $current, $ffq_prev, $drlast) + my ($status, $message, $current, $ffq_prev, $gdrlast) = ffq_prev_branchinfo(); return ($status, $message) unless $status eq 'branch'; @@ -1012,7 +1012,7 @@ sub record_ffq_prev_deferred () { fproblems_maybe_bail(); push @deferred_updates, "update $ffq_prev $currentval $git_null_obj"; - push @deferred_updates, "delete $drlast"; + push @deferred_updates, "delete $gdrlast"; push @deferred_update_messages, "Recorded current head for preservation"; return ('deferred', undef); } @@ -1026,6 +1026,33 @@ sub record_ffq_auto () { } } +sub stitch ($$$$$) { + my ($old_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose) = @_; + + push @deferred_updates, "delete $ffq_prev $ffq_prev_commitish"; + + if (is_fast_fwd $old_head, $ffq_prev_commitish) { + my $differs = get_differs $old_head, $ffq_prev_commitish; + unless ($differs & ~D_PAT_ADD) { + # ffq-prev is ahead of us, and the only tree changes it has + # are possibly addition of things in debian/patches/. + # Just wind forwards rather than making a pointless pseudomerge. + push @deferred_updates, + "update $gdrlast $ffq_prev_commitish $git_null_obj"; + update_head_checkout $old_head, $ffq_prev_commitish, + "stitch (fast forward)"; + return; + } + } + fresh_workarea(); + my $new_head = make_commit [ $old_head, $ffq_prev ], [ + 'Declare fast forward / record previous work', + "[git-debrebase pseudomerge: stitch$prose]", + ]; + push @deferred_updates, "update $gdrlast $new_head $git_null_obj"; + update_head $old_head, $new_head, "stitch"; +} + sub cmd_new_upstream_v0 () { # automatically and unconditionally launders before rebasing # if rebase --abort is used, laundering has still been done @@ -1224,6 +1251,12 @@ sub cmd_record_ffq_prev () { } } +sub cmd_anchor () { + badusage "no arguments allowed" if @ARGV; + my ($anchor, $bw) = keycommits +(git_rev_parse 'HEAD'), 0,0; + print "$bw\n" or die $!; +} + sub cmd_breakwater () { badusage "no arguments allowed" if @ARGV; my ($anchor, $bw) = keycommits +(git_rev_parse 'HEAD'), 0,0; @@ -1234,14 +1267,14 @@ sub cmd_stitch () { my $prose = ''; GetOptions('prose=s', \$prose) or die badusage("bad options to stitch"); badusage "no arguments allowed" if @ARGV; - my ($status, $message, $current, $ffq_prev, $drlast) + my ($status, $message, $current, $ffq_prev, $gdrlast) = ffq_prev_branchinfo(); if ($status ne 'branch') { fproblem $status, "could not check ffq-prev: $message"; fproblems_maybe_bail(); } - my $prev = $ffq_prev && git_get_ref $ffq_prev; - if (!$prev) { + my $ffq_prev_commitish = $ffq_prev && git_get_ref $ffq_prev; + if (!$ffq_prev_commitish) { fail "No ffq-prev to stitch." unless $opt_noop_ok; return; } @@ -1249,26 +1282,7 @@ sub cmd_stitch () { keycommits $old_head, \&fproblem, \&fproblem, \&fproblem; - push @deferred_updates, "delete $ffq_prev $prev"; - - if (is_fast_fwd $old_head, $prev) { - my $differs = get_differs $old_head, $prev; - unless ($differs & ~D_PAT_ADD) { - # ffq-prev is ahead of us, and the only tree changes it has - # are possibly addition of things in debian/patches/. - # Just wind forwards rather than making a pointless pseudomerge. - push @deferred_updates, "update $drlast $prev $git_null_obj"; - update_head_checkout $old_head, $prev, "stitch (fast forward)"; - return; - } - } - fresh_workarea(); - my $new_head = make_commit [ $old_head, $ffq_prev ], [ - 'Declare fast forward / record previous work', - "[git-debrebase pseudomerge: stitch$prose]", - ]; - push @deferred_updates, "update $drlast $new_head $git_null_obj"; - update_head $old_head, $new_head, "stitch"; + stitch($old_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose); } sub cmd_convert_from_gbp () { @@ -1343,7 +1357,7 @@ sub cmd_convert_from_gbp () { sub cmd_convert_to_gbp () { badusage "no arguments allowed" if @ARGV; my $head = get_head(); - my (undef, undef, undef, $ffq, $drlast) = ffq_prev_branchinfo(); + my (undef, undef, undef, $ffq, $gdrlast) = ffq_prev_branchinfo(); my ($anchor, $bw) = keycommits $head, 0; fresh_workarea(); my $out; @@ -1359,7 +1373,7 @@ sub cmd_convert_to_gbp () { }; if (defined $ffq) { push @deferred_updates, "delete $ffq"; - push @deferred_updates, "delete $drlast"; + push @deferred_updates, "delete $gdrlast"; } update_head_checkout $head, $out, "convert to gbp (v0)"; print <