chiark / gitweb /
absurd git-apply fallback: defend against debian/patches/series being an unusual...
[dgit.git] / dgit
diff --git a/dgit b/dgit
index ea14ba523ca15b4aeafe3637d43e11c4fab2ec00..62feb30281dacd5c0f1bb28aa5d109a9f9141c5b 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -75,7 +75,10 @@ our $tagformat;
 our $tagformatfn;
 
 our %forceopts = map { $_=>0 }
-    qw(unrepresentable unsupported-source-format);
+    qw(unrepresentable unsupported-source-format
+       dsc-changes-mismatch
+       import-gitapply-absurd
+       import-gitapply-no-absurd);
 
 our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
 
@@ -237,6 +240,14 @@ sub forceable_fail ($$) {
     print STDERR "warning: overriding problem due to --force:\n". $msg;
 }
 
+sub forceing ($) {
+    my ($forceoptsl) = @_;
+    my @got = grep { $forceopts{$_} } @$forceoptsl;
+    return 0 unless @got;
+    print STDERR
+ "warning: skipping checks or functionality due to --force-$got[0]\n";
+}
+
 sub no_such_package () {
     print STDERR "$us: package $package does not exist in suite $isuite\n";
     exit 4;
@@ -1967,9 +1978,15 @@ END
                $path = "$absurdity:$path";
                progress "$us: trying slow absurd-git-apply...";
                rename "../../gbp-pq-output","../../gbp-pq-output.0"
+                   or $!==ENOENT
                    or die $!;
            }
            eval {
+               die "forbid absurd git-apply\n" if $use_absurd
+                   && forceing [qw(import-gitapply-no-absurd)];
+               die "only absurd git-apply!\n" if !$use_absurd
+                   && forceing [qw(import-gitapply-absurd)];
+
                local $ENV{PATH} = $path if $use_absurd;
 
                my @showcmd = (gbp_pq, qw(import));
@@ -3291,7 +3308,8 @@ END
 
     # Check that changes and .dsc agree enough
     $changesfile =~ m{[^/]*$};
-    files_compare_inputs($dsc, parsecontrol($changesfile,$&));
+    files_compare_inputs($dsc, parsecontrol($changesfile,$&))
+       unless forceing [qw(dsc-changes-mismatch)];
 
     # Checks complete, we're going to try and go ahead:
 
@@ -5220,6 +5238,10 @@ sub parseopts () {
                push @ropts, $&;
                $forceopts{$1} = 1;
                $_='';
+           } elsif (m/^--force-/) {
+               print STDERR
+                   "$us: warning: ignoring unknown force option $_\n";
+               $_='';
            } elsif (m/^--dgit-tag-format=(old|new)$/s) {
                # undocumented, for testing
                push @ropts, $_;