#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"
return;
for (;;) {
- int cmp, len;
+ int cmp = cmp, len;
if (!fgets(buffer, sizeof(buffer), f)) {
fclose(f);
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;
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";
struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
int result = 0, i;
struct child_process rsync;
- const char *args[8];
+ const char *args[10];
/* first push the objects */
memset(&rsync, 0, sizeof(rsync));
rsync.argv = args;
rsync.stdout_to_stderr = 1;
- args[0] = "rsync";
- args[1] = transport->verbose ? "-av" : "-a";
- args[2] = "--ignore-existing";
- args[3] = "--exclude";
- args[4] = "info";
- args[5] = get_object_directory();;
- args[6] = buf.buf;
- args[7] = NULL;
+ i = 0;
+ args[i++] = "rsync";
+ args[i++] = "-a";
+ if (flags & TRANSPORT_PUSH_DRY_RUN)
+ args[i++] = "--dry-run";
+ if (transport->verbose > 0)
+ args[i++] = "-v";
+ args[i++] = "--ignore-existing";
+ args[i++] = "--exclude";
+ args[i++] = "info";
+ args[i++] = get_object_directory();
+ args[i++] = buf.buf;
+ args[i++] = NULL;
if (run_command(&rsync))
return error("Could not push objects to %s", transport->url);
} else if (write_refs_to_temp_dir(&temp_dir, refspec_nr, refspec))
return -1;
- i = (flags & TRANSPORT_PUSH_FORCE) ? 2 : 3;
+ i = 2;
+ if (flags & TRANSPORT_PUSH_DRY_RUN)
+ args[i++] = "--dry-run";
+ if (!(flags & TRANSPORT_PUSH_FORCE))
+ args[i++] = "--ignore-existing";
args[i++] = temp_dir.buf;
args[i++] = transport->url;
args[i++] = NULL;
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++)
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;
argv[argc++] = "--all";
if (flags & TRANSPORT_PUSH_FORCE)
argv[argc++] = "--force";
+ if (flags & TRANSPORT_PUSH_DRY_RUN)
+ argv[argc++] = "--dry-run";
argv[argc++] = transport->url;
while (refspec_nr--)
argv[argc++] = *refspec++;
return !!err;
}
-#ifndef NO_CURL
static int missing__target(int code, int result)
{
return /* file:// URL -- do we ever use one??? */
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 {
struct git_transport_data *data = transport->data;
struct ref *refs;
int fd[2];
- pid_t pid;
char *dest = xstrdup(transport->url);
-
- pid = git_connect(fd, dest, data->uploadpack, 0);
-
- if (pid < 0)
- die("Failed to connect to \"%s\"", transport->url);
+ struct child_process *conn = git_connect(fd, dest, data->uploadpack, 0);
get_remote_heads(fd[0], &refs, 0, NULL, 0);
packet_flush(fd[1]);
- finish_connect(pid);
+ finish_connect(conn);
free(dest);
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++)
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);
} 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)) {