chiark / gitweb /
git-debrebase: Break out begin_convert_from & complete_...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Aug 2018 21:45:49 +0000 (22:45 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Aug 2018 22:41:31 +0000 (23:41 +0100)
$gdrlastinfo is undef for now, and will be used in a moment.

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index 8e347f15843b71deb7ad9e0450ce37478a2c8b93..2e0882dfa6e2c9c70646d646c07db591e4c8b6e7 100755 (executable)
@@ -2409,6 +2409,18 @@ sub check_series_has_all_patches ($) {
     }
 }
 
+sub begin_convert_from () {
+    my $head = get_head();
+    return ($head, undef);
+}
+
+sub complete_convert_from ($$$$) {
+    my ($old_head, $new_head, $gi, $mrest) = @_;
+    ffq_check $new_head;
+    snags_maybe_bail();
+    update_head_checkout $old_head, $new_head, $mrest;
+}
+
 sub cmd_convert_from_gbp () {
     badusage "want only 1 optional argument, the upstream git commitish"
        unless @ARGV<=1;
@@ -2423,7 +2435,7 @@ sub cmd_convert_from_gbp () {
     my $upstream =
        resolve_upstream_version($upstream_spec, $upstream_version);
 
-    my $old_head = get_head();
+    my ($old_head, $gdrlastinfo) = begin_convert_from();
 
     my $upsdiff = get_differs $upstream, $old_head;
     if ($upsdiff & D_UPS) {
@@ -2537,9 +2549,7 @@ END
        }
     };
 
-    ffq_check $work;
-    snags_maybe_bail();
-    update_head_checkout $old_head, $work, 'convert-from-gbp';
+    complete_convert_from $old_head, $work, $gdrlastinfo, 'convert-from-gbp';
     print <<END or die $!;
 git-debrebase: converted from patched-unapplied (gbp) branch format, OK
 END
@@ -2599,7 +2609,7 @@ sub cmd_convert_from_dgit_view () {
                         };
     }
 
-    my $head = get_head();
+    my ($head, $gdrlastinfo) = begin_convert_from();
 
     if (!$always) {
        my $troubles = 0;
@@ -2755,9 +2765,7 @@ END
 
     printf STDERR "Yes, will base new branch on %s\n", $result->{Source};
 
-    ffq_check $result->{Result};
-    snags_maybe_bail();
-    update_head_checkout $head, $result->{Result},
+    complete_convert_from $head, $result->{Result}, $gdrlastinfo,
        'convert-from-dgit-view';
 }