chiark / gitweb /
Subprocess error handling: Fix when divert check fails
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jul 2016 22:35:21 +0000 (23:35 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Jul 2016 12:46:14 +0000 (13:46 +0100)
If the remote command failed, do not try to match the undef value
against the various regexps.

dgit

diff --git a/dgit b/dgit
index f60180c2b5e7a2ada68c4d688899851e519b6f94..54a1c154f30afa153951a5c6e7087e0a6f6b08bf 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1160,7 +1160,7 @@ sub check_for_git () {
             " set -e; cd ".access_cfg('git-path').";".
             " if test -d $package.git; then echo 1; else echo 0; fi");
        my $r= cmdoutput @cmd;
-       if ($r =~ m/^divert (\w+)$/) {
+       if (defined $r and $r =~ m/^divert (\w+)$/) {
            my $divert=$1;
            my ($usedistro,) = access_distros();
            # NB that if we are pushing, $usedistro will be $distro/push
@@ -1169,7 +1169,7 @@ sub check_for_git () {
            progress "diverting to $divert (using config for $instead_distro)";
            return check_for_git();
        }
-       failedcmd @cmd unless $r =~ m/^[01]$/;
+       failedcmd @cmd unless defined $r and $r =~ m/^[01]$/;
        return $r+0;
     } elsif ($how eq 'url') {
        my $prefix = access_cfg('git-check-url','git-url');