chiark / gitweb /
git-debrebase: new-upstream-v0: allow upstream to be omitted
[dgit.git] / git-debrebase
index 9f7eabe2453cbd39d477562e2247629dceaaff0d..2b38d4f85d2cdb89f95b3af03627d09b3516a5e8 100755 (executable)
@@ -22,9 +22,9 @@
 # usages:
 #
 #    git-debrebase [<options>] new-upstream-v0 \
-#             <new-version> <orig-commitish> \
+#             <new-version> [<orig-commitish> \
 #            [<extra-orig-name> <extra-orig-commitish> ...] \
-#            [<git-rebase options>...]
+#            [<git-rebase options>...]]
 #
 #    git-debrebase [<options> --] [<git-rebase options...>]
 #    git-debrebase [<options>] analyse
@@ -893,12 +893,7 @@ sub cmd_launder_v0 () {
 
 sub defaultcmd_rebase () {
     my $old = get_head();
-    my ($status, $message) = record_ffq_prev_deferred();
-    if ($status eq 'deferred' || $status eq 'exists') {
-    } else {
-       fproblem $status, "could not record ffq-prev: $message";
-       fproblems_maybe_bail();
-    }
+    record_ffq_auto();
     my ($tip,$breakwater) = walk $old;
     update_head_postlaunder $old, $tip, 'launder for rebase';
     runcmd @git, qw(rebase), @ARGV, $breakwater;
@@ -1015,19 +1010,30 @@ sub record_ffq_prev_deferred () {
     return ('deferred', undef);
 }
 
+sub record_ffq_auto () {
+    my ($status, $message) = record_ffq_prev_deferred();
+    if ($status eq 'deferred' || $status eq 'exists') {
+    } else {
+       fproblem $status, "could not record ffq-prev: $message";
+       fproblems_maybe_bail();
+    }
+}
+
 sub cmd_new_upstream_v0 () {
     # 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 >= 2;
+    badusage "need NEW-VERSION [UPS-COMMITTISH]" unless @ARGV >= 1;
 
     # parse args - low commitment
     my $new_version = (new Dpkg::Version scalar(shift @ARGV), check => 1);
     my $new_upstream_version = $new_version->version();
 
-    my $new_upstream = git_rev_parse shift @ARGV;
+    my $new_upstream = git_rev_parse (shift @ARGV // 'upstream');
+
+    record_ffq_auto();
 
     my $piece = sub {
         my ($n, @x) = @_; # may be ''
@@ -1064,13 +1070,13 @@ sub cmd_new_upstream_v0 () {
     # now we need to investigate the branch this generates the
     # laundered version but we don't switch to it yet
     my $old_head = get_head();
-    my ($old_laundered_tip,$old_bw,$old_upstream_update) = walk $old_head;
+    my ($old_laundered_tip,$old_bw,$old_anchor) = walk $old_head;
 
     my $old_bw_cl = classify $old_bw;
-    my $old_upstream_update_cl = classify $old_upstream_update;
-    confess unless $old_upstream_update_cl->{OrigParents};
+    my $old_anchor_cl = classify $old_anchor;
+    confess unless $old_anchor_cl->{OrigParents};
     my $old_upstream = parsecommit
-        $old_upstream_update_cl->{OrigParents}[0]{CommitId};
+        $old_anchor_cl->{OrigParents}[0]{CommitId};
 
     $piece->('', Old => $old_upstream->{CommitId});
 
@@ -1332,9 +1338,7 @@ sub cmd_convert_to_gbp () {
         ];
     };
     if (defined $ffq) {
-       runcmd @git, qw(update-ref -m),
-           "debrebase: converting corresponding main branch to gbp format",
-           $ffq, $git_null_obj;
+       push @deferred_updates, "delete $ffq";
     }
     update_head_checkout $head, $out, "convert to gbp (v0)";
     print <<END or die $!;