chiark / gitweb /
dgit: Add a comment about a bug we are about to eliminate.
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 70f28dc6f9023ed280778e8d0e9de9dc4b1be11c..e940224871590954d2fa7a1272ead350cb5b19fe 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -5817,11 +5817,34 @@ sub build_maybe_quilt_fixup () {
     my $clogp = parsechangelog();
     my $headref = git_rev_parse('HEAD');
     my $symref = git_get_symref();
+    my $upstreamversion = upstreamversion $version;
 
     prep_ud();
     changedir $playground;
 
-    my $upstreamversion = upstreamversion $version;
+    my $splitbrain_cachekey;
+
+    if ($do_split_brain) {
+       my $cachehit;
+       ($cachehit, $splitbrain_cachekey) =
+           quilt_check_splitbrain_cache($headref, $upstreamversion);
+       if ($cachehit) {
+           changedir $maindir;
+           return;
+       }
+    }
+
+    unpack_playtree_need_cd_work($headref);
+    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
+       #  unpack_playtree_need_cd_work
+       # will DTRT, resetting dgit-view.
+       die if $split_brain;
+       $split_brain = 1;
+    }
+    chdir '..';
 
     if ($fopts->{'single-debian-patch'}) {
        fail f_
@@ -5830,7 +5853,8 @@ sub build_maybe_quilt_fixup () {
            if quiltmode_splitbrain();
        quilt_fixup_singlepatch($clogp, $headref, $upstreamversion);
     } else {
-       quilt_fixup_multipatch($clogp, $headref, $upstreamversion);
+       quilt_fixup_multipatch($clogp, $headref, $upstreamversion,
+                             $splitbrain_cachekey);
     }
 
     changedir $maindir;
@@ -6056,7 +6080,7 @@ sub quilt_check_splitbrain_cache ($$) {
 }
 
 sub quilt_fixup_multipatch ($$$) {
-    my ($clogp, $headref, $upstreamversion) = @_;
+    my ($clogp, $headref, $upstreamversion, $splitbrain_cachekey) = @_;
 
     progress f_ "examining quilt state (multiple patches, %s mode)",
                $quilt_mode;
@@ -6130,8 +6154,6 @@ sub quilt_fixup_multipatch ($$$) {
     # afterwards with dpkg-source --before-build.  That lets us save a
     # tree object corresponding to .origs.
 
-    my $splitbrain_cachekey;
-
     if ($quilt_mode eq 'linear'
        && branch_is_gdr($headref)) {
        # This is much faster.  It also makes patches that gdr
@@ -6165,12 +6187,6 @@ sub quilt_fixup_multipatch ($$$) {
        chdir '..';
     }
 
-    if ($do_split_brain) {
-       my $cachehit;
-       ($cachehit, $splitbrain_cachekey) =
-           quilt_check_splitbrain_cache($headref, $upstreamversion);
-       return if $cachehit;
-    }
     my $unapplied=quilt_fakedsc2unapplied($headref, $upstreamversion);
 
     ensuredir '.pc';
@@ -6266,11 +6282,6 @@ END
     push @failsuggestion, [ 'origs', __
  "Maybe orig tarball(s) are not identical to git representation?" ];
 
-    if ($do_split_brain) {
-       runcmd @git, qw(checkout -q -b dgit-view);
-       die if $split_brain;
-       $split_brain = 1;
-    }
     if (quiltmode_splitbrain()) {
        quiltify_splitbrain($clogp, $unapplied, $headref, $oldtiptree,
                             $diffbits, \%editedignores,
@@ -7564,6 +7575,8 @@ sub parseopts_late_defaults () {
     }
 
     fail __ "dgit: --include-dirty is not supported in split view quilt mode"
+       # xxx this does not actually work, because $split brain is
+       #     not set this early
        if $split_brain && $includedirty;
 
     if (!defined $cleanmode) {