From 8b38c204c268e0e862036c273a6298ccc9ea46fd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 16 Jun 2018 21:32:11 +0100 Subject: [PATCH] git-debrebase: make_patches; Move get_differs into cmd_... 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 --- git-debrebase | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/git-debrebase b/git-debrebase index 634ed763..3cab3ad8 100755 --- a/git-debrebase +++ b/git-debrebase @@ -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 () { -- 2.30.2