chiark / gitweb /
Split brain: Start work on determining split brain necessity
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 08d07bec9190b600fac461f8ccb3bde037a593f2..7b9aa52d2e39453924f6d2df84a90554e912e7f2 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -83,6 +83,7 @@ our (@dpkgbuildpackage) = qw(dpkg-buildpackage -i\.git/ -I.git);
 our (@dpkgsource) = qw(dpkg-source -i\.git/ -I.git);
 our (@dpkggenchanges) = qw(dpkg-genchanges);
 our (@mergechanges) = qw(mergechanges -f);
+our (@gbppq) = qw(gbp-pq);
 our (@changesopts) = ('');
 
 our %opts_opt_map = ('dget' => \@dget, # accept for compatibility
@@ -114,6 +115,7 @@ autoflush STDOUT 1;
 
 our $supplementary_message = '';
 our $need_split_build_invocation = 0;
+our $split_brain = 0;
 
 END {
     local ($@, $?);
@@ -2537,15 +2539,33 @@ sub quiltify_tree_sentinelfiles ($) {
         qw(-- debian/rules debian/control);
     $r =~ s/\n/,/g;
     return $r;
+                                }
+
+sub quiltify_splitbrain_needed () {
+    if (!$split_brain) {
+       progress "creating dgit view";
+       runcmd @git, qw(checkout -q -b dgit-view);
+       $split_brain = 1;
+    }
 }
 
 sub quiltify_splitbrain ($) {
     my ($diffbits) = @_;
-    # memoisation via git-reflog
-    my $may_apply = $quilt_mode =~ m/gbp|unapplied/;
-    die "xxx not yet implemented";
-#    if ($may_apply &&
-#      quiltify_trees_differ($userhead,)) {}
+    if ($quilt_mode !~ m/gbp|dpm/) {
+       # treat .gitignore just like any other upstream file
+       $diffbits = { %$diffbits };
+       $_ = !!$_ foreach values %$diffbits;
+    }
+    if ($quilt_mode =~ m/gbp|unapplied/ &&
+       ($diffbits->{O2A} & 01) && # some patches
+       !($diffbits->{H2O} & 01)) { # but HEAD is like orig
+       quiltify_splitbrain_needed();
+       runcmd @gbppq, qw(import);
+       die "SPLIT BRAIN";
+    }
+    die 'xxx gitignore';
+    die 'xxx memoisation via git-reflog';
+    die 'xxx fast forward';
 }
 
 sub quiltify ($$$$) {
@@ -3034,7 +3054,7 @@ END
     push @failsuggestion, "Maybe you need to specify one of".
         " --quilt=gbp --quilt=dpm --quilt=unapplied ?";
 
-    if ($quilt_mode =~ m/gbp|dpm|apply/) {
+    if ($quilt_mode =~ m/gbp|dpm|unapplied/) {
        quiltify_splitbrain($diffbits);
        return;
     }