chiark / gitweb /
git-debrebase: Provide conclude subcommand
[dgit.git] / git-debrebase
index 882614195d2ba6068d8a989018f963ce429d8843..72b48288e7879ef4a799e8065de49a5e08f15bce 100755 (executable)
@@ -37,7 +37,8 @@ our $us = qw(git-debrebase);
 
 sub badusage ($) {
     my ($m) = @_;
-    die "bad usage: $m\n";
+    print STDERR "bad usage: $m\n";
+    exit 12;
 }
 
 sub cfg ($;$) {
@@ -503,7 +504,7 @@ sub keycommits ($;$$$) {
     # $dgitimport->("unclean-$tagsfx", $msg)
     #   is callled for each situation or commit that
     #   wouldn't be found in a laundered branch
-    # $furniture is forfurniture commits such as might be found on an
+    # $furniture is for furniture commits such as might be found on an
     #   interchange branch (pseudomerge, d/patches, changelog)
     # $trouble is for things whnich prevent the return of
     #   anchor and breakwater information; if that is ignored,
@@ -1065,10 +1066,25 @@ sub stitch ($$$$$) {
     fresh_workarea();
     my $new_head = make_commit [ $old_head, $ffq_prev ], [
        'Declare fast forward / record previous work',
-        "[git-debrebase pseudomerge: stitch$prose]",
+        "[git-debrebase pseudomerge: $prose]",
     ];
     push @deferred_updates, "update $gdrlast $new_head $git_null_obj";
-    update_head $old_head, $new_head, "stitch";
+    update_head $old_head, $new_head, "stitch: $prose";
+}
+
+sub do_stitch ($) {
+    my ($prose) = @_;
+
+    my ($ffq_prev, $gdrlast, $ffq_prev_commitish) = ffq_prev_info();
+    if (!$ffq_prev_commitish) {
+       fail "No ffq-prev to stitch." unless $opt_noop_ok;
+       return;
+    }
+    my $dangling_head = get_head();
+
+    keycommits $dangling_head, \&snag, \&snag, \&snag;
+
+    stitch($dangling_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose);
 }
 
 sub cmd_new_upstream_v0 () {
@@ -1282,20 +1298,16 @@ sub cmd_breakwater () {
 }
 
 sub cmd_stitch () {
-    my $prose = '';
+    my $prose = 'stitch';
     GetOptions('prose=s', \$prose) or die badusage("bad options to stitch");
     badusage "no arguments allowed" if @ARGV;
+    do_stitch($prose);
+}
 
-    my ($ffq_prev, $gdrlast, $ffq_prev_commitish) = ffq_prev_info();
-    if (!$ffq_prev_commitish) {
-       fail "No ffq-prev to stitch." unless $opt_noop_ok;
-       return;
-    }
-    my $old_head = get_head();
-
-    keycommits $old_head, \&snag, \&snag, \&snag;
-
-    stitch($old_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose);
+sub cmd_conclude () {
+    badusage "no arguments allowed" if @ARGV;
+    do_launder_head 'launder for conclude';
+    do_stitch 'conclude';
 }
 
 sub cmd_convert_from_gbp () {