chiark / gitweb /
dgit: Use libcurl, not @curl, for git check
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 0f801a3d30127b518b393481e55842bde52a9d20..978eabe84494bb1c01b02689da9fe2ce2345aa53 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1804,22 +1804,11 @@ sub check_for_git () {
        my $suffix = access_cfg('git-check-suffix','git-suffix',
                                'RETURN-UNDEF') // '.git';
        my $url = "$prefix/$package$suffix";
-       my @cmd = (@curl, qw(-sS -I), $url);
-       my $result = cmdoutput @cmd;
-       $result =~ s/^\S+ 200 .*\n\r?\n//;
-       # curl -sS -I with https_proxy prints
-       # HTTP/1.0 200 Connection established
-       $result =~ m/^\S+ (404|200) /s or
-           fail +(__ "unexpected results from git check query - ").
-               Dumper($prefix, $result);
-       my $code = $1;
-       if ($code eq '404') {
-           return 0;
-       } elsif ($code eq '200') {
-           return 1;
-       } else {
-           die;
-       }
+       my $result = url_fetch $url,
+           CurlOpts => { CURLOPT_NOBODY() => 1 },
+           Ok404 => 1,
+           AccessBase => 'git-check';
+       return defined $result;
     } elsif ($how eq 'true') {
        return 1;
     } elsif ($how eq 'false') {