chiark / gitweb /
git-debrebase: make_patches; Move get_differs into cmd_...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 20:32:11 +0000 (21:32 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 22:25:50 +0000 (23:25 +0100)
We want to make the error handling dependent on options, etc.  Moving
the differs analysis into cmd_make_patches avoids having a complex
calling convention for make_patches.

No functional change.

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

index 634ed763b1989edd2c9607b0cccdbcffae8b8019..3cab3ad8837b4a28a4bc51be3bcad29d123ebd20 100755 (executable)
@@ -1501,28 +1501,25 @@ sub make_patches ($) {
             '[git-debrebase: export and commit patches]',
         ];
     };
-    my $d = get_differs $head, $out;
-    if ($d == 0) {
-       return undef; # nothing to do
-    } elsif ($d == D_PAT_ADD) {
-       return $out; # OK
-    } else {
-       fail "Patch export produced patch amendments".
-           " (abandoned output commit $out).".
-           "  Try laundering first.";
-    }
+    return $out;
 }
 
 sub cmd_make_patches () {
     badusage "no arguments allowed" if @ARGV;
     my $old_head = get_head();
     my $new = make_patches $old_head;
-    snags_maybe_bail();
-    if (!$new) {
+    my $d = get_differs $old_head, $new;
+    if ($d == 0) {
        fail "No (more) patches to export." unless $opt_noop_ok;
        return;
+    } elsif ($d == D_PAT_ADD) {
+       snags_maybe_bail();
+       update_head_checkout $old_head, $new, 'make-patches';
+    } else {
+       fail "Patch export produced patch amendments".
+           " (abandoned output commit $new).".
+           "  Try laundering first.";
     }
-    update_head_checkout $old_head, $new, 'make-patches';
 }
 
 sub cmd_convert_from_gbp () {