chiark / gitweb /
better error msgs from check_not_dirty
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 93fb6fcd2a47beff177cab661b9a316ef2046958..b3a4e9b7fc10252debef9133c3010f6be52ac498 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -28,6 +28,7 @@ use Dpkg::Version;
 use POSIX;
 
 our $isuite = 'unstable';
+our $idistro;
 our $package;
 
 our $sign = 1;
@@ -246,7 +247,7 @@ sub access_distro () {
 
 sub access_cfg (@) {
     my (@keys) = @_;
-    my $distro = access_distro();
+    my $distro = $idistro || access_distro();
     my $value = cfg(map { ("dgit-distro.$distro.$_",
                           "dgit.default.$_") } @keys);
     return $value;
@@ -706,7 +707,15 @@ sub pull () {
 }
 
 sub check_not_dirty () {
-    runcmd @git, qw(diff --quiet HEAD);
+    my @cmd = (@git, qw(diff --quiet HEAD));
+    printcmd(\*DEBUG,"+",@cmd) if $debug>0;
+    $!=0; $?=0; system @cmd;
+    return if !$! && !$?;
+    if (!$! && $?==256) {
+       fail "working tree is dirty (does not match HEAD)";
+    } else {
+       failedcmd @cmd;
+    }
 }
 
 sub commit_quilty_patch ($) {
@@ -978,6 +987,8 @@ sub parseopts () {
                push @$om, $2;
            } elsif (m/^--existing-package=(.*)/s) {
                $existing_package = $1;
+           } elsif (m/^--distro=(.*)/s) {
+               $idistro = $1;
            } else {
                badusage "unknown long option \`$_'";
            }
@@ -994,6 +1005,8 @@ sub parseopts () {
                    $new_package=1;
                } elsif (s/^-c(.*=.*)//s) {
                    push @git, '-c', $1;
+               } elsif (s/^-d(.*)//s) {
+                   $idistro = $1;
                } elsif (s/^-C(.*)//s) {
                    $changesfile = $1;
                } elsif (s/^-k(.*)//s) {