chiark / gitweb /
dgit: Break out api_query_raw
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 0e0ff6575c3e79bc67227b809e36c876b53fb4f1..80adf1fdbba1e9f10361aa0e4573b990f901c67b 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -4,7 +4,7 @@
 #
 # Copyright (C)2013-2019 Ian Jackson
 # Copyright (C)2017-2019 Sean Whitton
-# Copyright (C)2019      Matthew Vernon / Sanger Institute
+# Copyright (C)2019      Matthew Vernon / Genome Research Limited
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -117,7 +117,6 @@ our $rewritemap = 'dgit-rewrite/map';
 
 our @dpkg_source_ignores = qw(-i(?:^|/)\.git(?:/|$) -I.git);
 
-our (@git) = qw(git);
 our (@dget) = qw(dget);
 our (@curl) = (qw(curl --proto-redir), '-all,http,https', qw(-L));
 our (@dput) = qw(dput);
@@ -1224,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;
@@ -1241,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);
 }
 
@@ -1835,7 +1841,7 @@ sub prep_ud () {
 }
 
 sub mktree_in_ud_here () {
-    playtree_setup $gitcfgs{local};
+    playtree_setup();
 }
 
 sub git_write_tree () {
@@ -3883,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";
     }