}
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,
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 () {
# 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';
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);
}
}
}
+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
}
}
+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;
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;
}
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 () {
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;
};
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 <<END or die $!;