X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=git-debrebase;h=b83cceb365acaaa1ec253a13a506db4f1e919b40;hb=c8ff64a45b1fbc8484c19b16df0adc3f39150a51;hp=85cf331835002b313fc761f13acc537aee93e56a;hpb=880af0a90f1b02db4607e94d38555f2e86af47a3;p=dgit.git diff --git a/git-debrebase b/git-debrebase index 85cf3318..b83cceb3 100755 --- a/git-debrebase +++ b/git-debrebase @@ -22,14 +22,17 @@ # usages: # # git-debrebase [] new-upstream-v0 \ -# -# [ ...] +# \ +# [ ...] \ # [...] # # git-debrebase [ --] [] # git-debrebase [] analyse # git-debrebase [] launder # prints breakwater tip etc. # git-debrebase [] downstream-rebase-launder-v0 # experimental +# +# git-debrebase [] gbp2debrebase-v0 \ +# # problems / outstanding questions: # @@ -249,6 +252,26 @@ sub make_commit ($$) { return cmdoutput @cmd; } +our $fproblems; +sub fproblem ($) { + my ($msg) = @_; + $fproblems++; + print STDERR "git-debrebase: safety catch tripped: $msg\n"; +} +sub fproblems_maybe_bail () { + if ($fproblems) { + if ($opt_force) { + printf STDERR + "safety catch trips (%d) overriden by --force\n", + $fproblems; + } else { + fail sprintf + "safety catch trips (%d) (you could --force)", + $fproblems; + } + } +} + # classify returns an info hash like this # CommitId => $objid # Hdr => # commit headers, including 1 final newline @@ -850,13 +873,6 @@ sub cmd_new_upstream_v0 () { my $old_upstream = parsecommit $old_upstream_update_cl->{OrigParents}[0]{CommitId}; - my $problems = 0; - my $problem = sub { - my ($msg) = @_; - $problems++; - print STDERR "preflight check failed: $msg\n"; - }; - $piece->('', Old => $old_upstream->{CommitId}); if ($old_upstream->{Msg} =~ m{^\[git-debrebase }m) { @@ -870,35 +886,25 @@ sub cmd_new_upstream_v0 () { $piece->($n, Old => $old_upstream->{CommitId}.'^'.$parentix); } } else { - $problem->("previous upstream $old_upstream->{CommitId} is from". - " git-debrebase but not a \`new-upstream combine' commit"); + fproblem "previous upstream $old_upstream->{CommitId} is from". + " git-debrebase but not an \`upstream combine' commit"; } } foreach my $pc (values %pieces) { if (!$pc->{Old}) { - $problem->("introducing upstream piece \`$pc->{Name}'"); + fproblem "introducing upstream piece \`$pc->{Name}'"; } elsif (!$pc->{New}) { - $problem->("dropping upstream piece \`$pc->{Name}'"); + fproblem "dropping upstream piece \`$pc->{Name}'"; } elsif (!is_fast_fwd $pc->{Old}, $pc->{New}) { - $problem->("not fast forward: $pc->{Name} $pc->{Old}..$pc->{New}"); + fproblem "not fast forward: $pc->{Name} $pc->{Old}..$pc->{New}"; } } printdebug "%pieces = ", (dd \%pieces), "\n"; printdebug "\@newpieces = ", (dd \@newpieces), "\n"; - if ($problems) { - if ($opt_force) { - printf STDERR - "preflight check failures (%d) overriden by --force\n", - $problems; - } else { - fail sprintf - "preflight check failures (%d) (you could --force)", - $problems; - } - } + fproblems_maybe_bail(); my $new_bw;