Code

Merge branch 'master' into db/fetch-pack
[git.git] / transport.c
index 7266fd3dc7ff376cacd9d958da8fd58bc70585b1..e363c11c052bcd47401068c5caad0e34f72d87b8 100644 (file)
@@ -1,7 +1,9 @@
 #include "cache.h"
 #include "transport.h"
 #include "run-command.h"
+#ifndef NO_CURL
 #include "http.h"
+#endif
 #include "pkt-line.h"
 #include "fetch-pack.h"
 #include "walker.h"
@@ -161,7 +163,7 @@ static struct ref *get_refs_via_rsync(const struct transport *transport)
        rsync.argv = args;
        rsync.stdout_to_stderr = 1;
        args[0] = "rsync";
-       args[1] = transport->verbose ? "-rv" : "-r";
+       args[1] = (transport->verbose > 0) ? "-rv" : "-r";
        args[2] = buf.buf;
        args[3] = temp_dir.buf;
        args[4] = NULL;
@@ -214,7 +216,7 @@ static int fetch_objs_via_rsync(struct transport *transport,
        rsync.argv = args;
        rsync.stdout_to_stderr = 1;
        args[0] = "rsync";
-       args[1] = transport->verbose ? "-rv" : "-r";
+       args[1] = (transport->verbose > 0) ? "-rv" : "-r";
        args[2] = "--ignore-existing";
        args[3] = "--exclude";
        args[4] = "info";
@@ -290,7 +292,7 @@ static int rsync_transport_push(struct transport *transport,
        rsync.argv = args;
        rsync.stdout_to_stderr = 1;
        args[0] = "rsync";
-       args[1] = transport->verbose ? "-av" : "-a";
+       args[1] = (transport->verbose > 0) ? "-av" : "-a";
        args[2] = "--ignore-existing";
        args[3] = "--exclude";
        args[4] = "info";
@@ -344,7 +346,7 @@ static int fetch_objs_via_walker(struct transport *transport,
        walker->get_all = 1;
        walker->get_tree = 1;
        walker->get_history = 1;
-       walker->get_verbosely = transport->verbose;
+       walker->get_verbosely = transport->verbose >= 0;
        walker->get_recover = 0;
 
        for (i = 0; i < nr_objs; i++)
@@ -368,6 +370,7 @@ static int disconnect_walker(struct transport *transport)
        return 0;
 }
 
+#ifndef NO_CURL
 static int curl_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags) {
        const char **argv;
        int argc;
@@ -400,7 +403,6 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
        return !!err;
 }
 
-#ifndef NO_CURL
 static int missing__target(int code, int result)
 {
        return  /* file:// URL -- do we ever use one??? */
@@ -504,21 +506,6 @@ static int fetch_objs_via_curl(struct transport *transport,
        return fetch_objs_via_walker(transport, nr_objs, to_fetch);
 }
 
-#else
-
-static struct ref *get_refs_via_curl(const struct transport *transport)
-{
-       die("Cannot fetch from '%s' without curl ...", transport->url);
-       return NULL;
-}
-
-static int fetch_objs_via_curl(struct transport *transport,
-                                int nr_objs, struct ref **to_fetch)
-{
-       die("Cannot fetch from '%s' without curl ...", transport->url);
-       return -1;
-}
-
 #endif
 
 struct bundle_transport_data {
@@ -637,7 +624,7 @@ static int fetch_refs_via_pack(struct transport *transport,
        args.keep_pack = data->keep;
        args.lock_pack = 1;
        args.use_thin_pack = data->thin;
-       args.verbose = transport->verbose;
+       args.verbose = transport->verbose > 0;
        args.depth = data->depth;
 
        for (i = 0; i < nr_heads; i++)
@@ -667,6 +654,8 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
                argv[argc++] = "--all";
        if (flags & TRANSPORT_PUSH_FORCE)
                argv[argc++] = "--force";
+       if (flags & TRANSPORT_PUSH_DRY_RUN)
+               argv[argc++] = "--dry-run";
        if (data->receivepack) {
                char *rp = xmalloc(strlen(data->receivepack) + 16);
                sprintf(rp, "--receive-pack=%s", data->receivepack);
@@ -733,9 +722,13 @@ struct transport *transport_get(struct remote *remote, const char *url)
        } else if (!prefixcmp(url, "http://")
                || !prefixcmp(url, "https://")
                || !prefixcmp(url, "ftp://")) {
+#ifdef NO_CURL
+               error("git was compiled without libcurl support.");
+#else
                ret->get_refs_list = get_refs_via_curl;
                ret->fetch = fetch_objs_via_curl;
                ret->push = curl_transport_push;
+#endif
                ret->disconnect = disconnect_walker;
 
        } else if (is_local(url) && is_file(url)) {