chiark / gitweb /
dgit: Crash if we forgot to set $do_split_brain
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 66f2470c6be8e7f2054d237d8a92806f0c004ea7..89b14df7fb4e7ea58f5bf8fc327293150132bde4 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -173,7 +173,7 @@ autoflush STDOUT 1;
 
 our $supplementary_message = '';
 our $made_split_brain = 0;
-our $do_split_brain = 0;
+our $do_split_brain;
 
 # Interactions between quilt mode and split brain
 # (currently, split brain only implemented iff
@@ -189,7 +189,7 @@ our $do_split_brain = 0;
 #
 #   no split          no q cache        no q cache          forbidden,
 #     brain           PM on master      q fixup on master   prevented
-#   !$do_split_brain                    PM on master
+#   !do_split_brain()                    PM on master
 #
 #   split brain       no q cache        q fixup cached, to dgit view
 #                     PM in dgit view   PM in dgit view
@@ -214,11 +214,6 @@ if (!defined $absurdity) {
     $absurdity =~ s{/[^/]+$}{/absurd} or die;
 }
 
-sub debiantag ($$) {
-    my ($v,$distro) = @_;
-    return debiantag_new($v, $distro);
-}
-
 sub madformat ($) { $_[0] eq '3.0 (quilt)' }
 
 sub lbranch () { return "$branchprefix/$csuite"; }
@@ -300,6 +295,8 @@ sub quiltmode_splitbrain () {
     $quilt_mode =~ m/gbp|dpm|unapplied/;
 }
 
+sub do_split_brain () { !!($do_split_brain // confess) }
+
 sub opts_opt_multi_cmd {
     my $extra = shift;
     my @cmd;
@@ -2927,11 +2924,7 @@ sub git_fetch_us () {
     # deliberately-not-ff, in which case we must fetch everything.
 
     my @specs = deliberately_not_fast_forward ? qw(tags/*) :
-       map { "tags/$_" }
-       (quiltmode_splitbrain
-        ? (map { $_->('*',access_nomdistro) }
-           \&debiantag_new, \&debiantag_maintview)
-        : debiantags('*',access_nomdistro));
+       map { "tags/$_" } debiantags('*',access_nomdistro);
     push @specs, server_branch($csuite);
     push @specs, $rewritemap;
     push @specs, qw(heads/*) if deliberately_not_fast_forward;
@@ -4234,7 +4227,7 @@ sub push_parse_changelog ($) {
 
     if (!$we_are_initiator) {
        # rpush initiator can't do this because it doesn't have $isuite yet
-       my $tag = debiantag($cversion, access_nomdistro);
+       my $tag = debiantag_new($cversion, access_nomdistro);
        runcmd @git, qw(check-ref-format), $tag;
     }
 
@@ -4258,7 +4251,7 @@ sub push_tagwants ($$$$) {
     my ($cversion, $dgithead, $maintviewhead, $tfbase) = @_;
     my @tagwants;
     push @tagwants, {
-        TagFn => \&debiantag,
+        TagFn => \&debiantag_new,
        Objid => $dgithead,
         TfSuffix => '',
         View => 'dgit',
@@ -4462,7 +4455,7 @@ END
 
     if (madformat_wantfixup($format)) {
        # user might have not used dgit build, so maybe do this now:
-       if ($do_split_brain) {
+       if (do_split_brain()) {
            changedir $playground;
            my $cachekey;
            ($dgithead, $cachekey) =
@@ -4472,13 +4465,13 @@ END
  perhaps HEAD changed since dgit build[-source] ?",
                               $quilt_mode;
        }
-       if (!$do_split_brain) {
+       if (!do_split_brain()) {
            # In split brain mode, do not attempt to incorporate dirty
            # stuff from the user's working tree.  That would be mad.
            commit_quilty_patch();
        }
     }
-    if ($do_split_brain) {
+    if (do_split_brain()) {
        $made_split_brain = 1;
        $dgithead = splitbrain_pseudomerge($clogp,
                                           $actualhead, $dgithead,
@@ -4513,7 +4506,7 @@ END
        }
     }
 
-    confess unless !!$made_split_brain == !!$do_split_brain;
+    confess unless !!$made_split_brain == do_split_brain();
 
     changedir $playground;
     progress f_ "checking that %s corresponds to HEAD", $dscfn;
@@ -5358,7 +5351,7 @@ sub quiltify_splitbrain ($$$$$$$) {
     local $ENV{GIT_AUTHOR_EMAIL} = $authline[1];
     local $ENV{GIT_AUTHOR_DATE} =  $authline[2];
 
-    confess unless $do_split_brain;
+    confess unless do_split_brain();
 
     my $fulldiffhint = sub {
        my ($x,$y) = @_;
@@ -5744,7 +5737,7 @@ sub build_maybe_quilt_fixup () {
 
     my $splitbrain_cachekey;
 
-    if ($do_split_brain) {
+    if (do_split_brain()) {
        my $cachehit;
        ($cachehit, $splitbrain_cachekey) =
            quilt_check_splitbrain_cache($headref, $upstreamversion);
@@ -5755,7 +5748,7 @@ sub build_maybe_quilt_fixup () {
     }
 
     unpack_playtree_need_cd_work($headref);
-    if ($do_split_brain) {
+    if (do_split_brain()) {
        runcmd @git, qw(checkout -q -b dgit-view);
        # so long as work is not deleted, its current branch will
        # remain dgit-view, rather than master, so subsequent calls to
@@ -5777,7 +5770,7 @@ sub build_maybe_quilt_fixup () {
                              $splitbrain_cachekey);
     }
 
-    if ($do_split_brain) {
+    if (do_split_brain()) {
        my $dgitview = git_rev_parse 'HEAD';
 
        changedir $maindir;
@@ -6217,7 +6210,7 @@ END
 
     progress f_ "starting quiltify (multiple patches, %s mode)", $quilt_mode;
     quiltify($clogp,$headref,$oldtiptree,\@failsuggestion);
-    runcmd @git, qw(checkout -q), (qw(master dgit-view)[!!$do_split_brain]);
+    runcmd @git, qw(checkout -q), (qw(master dgit-view)[do_split_brain()]);
 
     if (!open P, '>>', ".pc/applied-patches") {
        $!==&ENOENT or confess "$!";
@@ -6373,8 +6366,9 @@ sub build_or_push_prep_modes () {
     if (madformat_wantfixup($format) && quiltmode_splitbrain()) {
        $do_split_brain = 1;
     }
+    $do_split_brain //= 0;
     fail __ "dgit: --include-dirty is not supported in split view quilt mode"
-       if $do_split_brain && $includedirty;
+       if do_split_brain() && $includedirty;
 }
 
 sub build_prep_early () {
@@ -6702,7 +6696,7 @@ sub build_source {
        unlink "$buildproductsdir/$sourcechanges" or $!==ENOENT
            or fail f_ "remove %s: %s", $sourcechanges, $!;
     }
-#    confess unless !!$made_split_brain == !!$do_split_brain;
+#    confess unless !!$made_split_brain == do_split_brain();
 
     my @cmd = (@dpkgsource, qw(-b --));
     my $leafdir;