chiark / gitweb /
dgit: dopush pseudomerge, break apart from quilt fixup
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 97557ce1c3e1c3a4042160a8c2ab99359184330b..cf12faeafe3cc048c940712e3e3f431b256644de 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -176,6 +176,7 @@ autoflush STDOUT 1;
 
 our $supplementary_message = '';
 our $split_brain = 0;
+our $do_split_brain = 0;
 
 END {
     local ($@, $?);
@@ -4492,6 +4493,7 @@ END
     if (madformat_wantfixup($format)) {
        # user might have not used dgit build, so maybe do this now:
        if (quiltmode_splitbrain()) {
+           $do_split_brain = 1;
            changedir $playground;
            quilt_make_fake_dsc($upstreamversion);
            my $cachekey;
@@ -4501,17 +4503,22 @@ END
  "--quilt=%s but no cached dgit view:
  perhaps HEAD changed since dgit build[-source] ?",
                               $quilt_mode;
-           $split_brain = 1;
-           $dgithead = splitbrain_pseudomerge($clogp,
-                                              $actualhead, $dgithead,
-                                              $archive_hash);
-           $maintviewhead = $actualhead;
-           changedir $maindir;
-           prep_ud(); # so _only_subdir() works, below
-       } else {
+       }
+       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) {
+       $split_brain = 1;
+       $dgithead = splitbrain_pseudomerge($clogp,
+                                          $actualhead, $dgithead,
+                                          $archive_hash);
+       $maintviewhead = $actualhead;
+       changedir $maindir;
+       prep_ud(); # so _only_subdir() works, below
+    }
 
     if (defined $overwrite_version && !defined $maintviewhead
        && $archive_hash) {
@@ -5394,6 +5401,7 @@ sub quiltify_splitbrain ($$$$$$$) {
     local $ENV{GIT_AUTHOR_DATE} =  $authline[2];
 
     die if $split_brain;
+    die unless $do_split_brain;
     runcmd @git, qw(checkout -q -b dgit-view);
     $split_brain = 1;
 
@@ -5783,12 +5791,7 @@ sub build_maybe_quilt_fixup () {
 
     check_for_vendor_patches();
 
-    if (quiltmode_splitbrain) {
-       fail <<END unless access_cfg_tagformats_can_splitbrain;
-quilt mode $quilt_mode requires split view so server needs to support
- both "new" and "maint" tag formats, but config says it doesn't.
-END
-    }
+    $do_split_brain = 1 if quiltmode_splitbrain();
 
     my $clogp = parsechangelog();
     my $headref = git_rev_parse('HEAD');
@@ -5839,6 +5842,17 @@ END
         @git, qw(pull --ff-only -q), "$playground/work", qw(master);
 }
 
+sub build_check_quilt_splitbrain () {
+    build_maybe_quilt_fixup();
+
+    if ($do_split_brain) {
+       fail <<END unless access_cfg_tagformats_can_splitbrain;
+quilt mode $quilt_mode requires split view so server needs to support
+ both "new" and "maint" tag formats, but config says it doesn't.
+END
+    }
+}
+
 sub unpack_playtree_mkwork ($) {
     my ($headref) = @_;
 
@@ -6393,7 +6407,7 @@ sub build_prep ($) {
        # said -wc we should still do the check.
        clean_tree_check();
     }
-    build_maybe_quilt_fixup();
+    build_check_quilt_splitbrain();
     if ($rmchanges) {
        my $pat = changespat $version;
        foreach my $f (glob "$buildproductsdir/$pat") {
@@ -6773,7 +6787,7 @@ sub cmd_push_source {
        "dgit push-source: --include-dirty/--ignore-dirty does not make".
        "sense with push-source!"
        if $includedirty;
-    build_maybe_quilt_fixup();
+    build_check_quilt_splitbrain();
     if ($changesfile) {
         my $changes = parsecontrol("$buildproductsdir/$changesfile",
                                    __ "source changes file");