chiark / gitweb /
dgit: Break out api_query_raw
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 2d6eb858f91703ae29f4dd7889049cc56a280cad..80adf1fdbba1e9f10361aa0e4573b990f901c67b 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1223,8 +1223,7 @@ sub archive_api_query_cmd ($) {
     return @cmd;
 }
 
-sub api_query ($$;$) {
-    use JSON;
+sub api_query_raw ($$;$) {
     my ($data, $subpath, $ok404) = @_;
     badcfg __ "ftpmasterapi archive query method takes no data part"
        if length $data;
@@ -1240,6 +1239,14 @@ sub api_query ($$;$) {
     return undef if $code eq '404' && $ok404;
     fail f_ "fetch of %s gave HTTP code %s", $url, $code
        unless $url =~ m#^file://# or $code =~ m/^2/;
+    return $json;
+}
+
+sub api_query ($$;$) {
+    my ($data, $subpath, $ok404) = @_;
+    use JSON;
+    my $json = api_query_raw $data, $subpath, $ok404;
+    return undef unless defined $json;
     return decode_json($json);
 }
 
@@ -3882,14 +3889,9 @@ sub clone ($) {
     record_maindir();
     setup_new_tree();
     clone_set_head();
-    my $giturl = access_giturl(1);
-    if (defined $giturl) {
-       runcmd @git, qw(remote add), 'origin', $giturl;
-    }
     if ($hasgit) {
        progress __ "fetching existing git history";
        git_fetch_us();
-       runcmd_ordryrun_local @git, qw(fetch origin);
     } else {
        progress __ "starting new git history";
     }