chiark / gitweb /
Split brain: Detect patches-unapplied tree and print a suitable message
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Jun 2016 11:23:16 +0000 (12:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jul 2016 15:47:47 +0000 (16:47 +0100)
Note that the message refers to `--quilt=gbp' aka `--quilt=apply'
which do not exist yet (and which we're going to call something else,
later in this series).  Oh well.

dgit

diff --git a/dgit b/dgit
index 370986de49a919f60c26e37cedb821edd674148b..4d7c7219f80ce2ab52d2e712e33399a40313b541 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2533,6 +2533,13 @@ sub quiltify_tree_sentinelfiles ($) {
     return $r;
 }
 
     return $r;
 }
 
+sub quilt_could_gbp ($$$) {
+    my ($userhead,$unapplied,$applied) = @_;
+    return
+       !quiltify_trees_differ($userhead,$unapplied,1) &&
+       quiltify_trees_differ($userhead,$applied,1);
+}
+
 sub quiltify ($$$) {
     my ($clogp,$target,$unapplied) = @_;
 
 sub quiltify ($$$) {
     my ($clogp,$target,$unapplied) = @_;
 
@@ -2678,6 +2685,12 @@ sub quiltify ($$$) {
            foreach my $notp (@nots) {
                print STDERR "$us:  ", $reportnot->($notp), "\n";
            }
            foreach my $notp (@nots) {
                print STDERR "$us:  ", $reportnot->($notp), "\n";
            }
+           if (quilt_could_gbp($target,$unapplied,$oldtiptree)) {
+               print STDERR <<END;
+$us: Tree looks like a patches-unapplied git branch.
+$us: Maybe you forgot --quilt=gbp (aka --quilt=apply) ?
+END
+           }
            fail "quilt fixup naive history linearisation failed.\n".
  "Use dpkg-source --commit by hand; or, --quilt=smash for one ugly patch";
        } elsif ($quilt_mode eq 'smash') {
            fail "quilt fixup naive history linearisation failed.\n".
  "Use dpkg-source --commit by hand; or, --quilt=smash for one ugly patch";
        } elsif ($quilt_mode eq 'smash') {
@@ -2884,11 +2897,24 @@ sub quilt_fixup_multipatch ($$$) {
     #     6. Back in the main tree, fast forward to the new HEAD
 
     # Another situation we may have to cope with is gbp-style
     #     6. Back in the main tree, fast forward to the new HEAD
 
     # Another situation we may have to cope with is gbp-style
-    # patches-unapplied trees.  We want to detect these, so we know
-    # to escape into quilt_fixup_gbp.
+    # patches-unapplied trees.
+    #
+    # We would want to detect these, so we know to escape into
+    # quilt_fixup_gbp.  However, this is in general not possible.
+    # Consider a package with a one patch which the dgit user reverts
+    # (with git-revert or the moral equivalent).
+    #
+    # That is indistinguishable in contents from a patches-unapplied
+    # tree.  And looking at the history to distinguish them is not
+    # useful because the user might have made a confusing-looking git
+    # history structure (which ought to produce an error if dgit can't
+    # cope, not a silent reintroduction of an unwanted patch).
     #
     #
-    # A gbp-style tree is one which is not a clean patches-applied
-    # tree, but _is_ a clean patches-unapplied tree.
+    # So gbp users will have to pass an option.  But we can usually
+    # detect their failure to do so: if the tree is not a clean
+    # patches-applied tree, quilt linearisation fails, but the tree
+    # _is_ a clean patches-unapplied tree, we can suggest that maybe
+    # they want --quilt=unapplied.
     #
     # To help detect this, when we are extracting the fake dsc, we
     # first extract it with --skip-patches, and then apply the patches
     #
     # To help detect this, when we are extracting the fake dsc, we
     # first extract it with --skip-patches, and then apply the patches