X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=remote-curl.c;h=350d92a074ed82a99060cebb1a4a3fb0a98cfd8e;hb=d45d771978c3d5bead096934cad16ddfb9fced37;hp=051f26629d7b9f6679e47f6dc353f09c16c377ae;hpb=ceca45541d0046544cc95acb6b849c14637e0e3e;p=thirdparty%2Fgit.git diff --git a/remote-curl.c b/remote-curl.c index 051f26629d..350d92a074 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -40,7 +40,8 @@ struct options { push_cert : 2, deepen_relative : 1, from_promisor : 1, - no_dependents : 1; + no_dependents : 1, + atomic : 1; }; static struct options options; static struct string_list cas_options = STRING_LIST_INIT_DUP; @@ -148,6 +149,14 @@ static int set_option(const char *name, const char *value) else return -1; return 0; + } else if (!strcmp(name, "atomic")) { + if (!strcmp(value, "true")) + options.atomic = 1; + else if (!strcmp(value, "false")) + options.atomic = 0; + else + return -1; + return 0; } else if (!strcmp(name, "push-option")) { if (*value != '"') string_list_append(&options.push_options, value); @@ -1154,7 +1163,7 @@ static void parse_fetch(struct strbuf *buf) strbuf_reset(buf); } -static int push_dav(int nr_spec, char **specs) +static int push_dav(int nr_spec, const char **specs) { struct child_process child = CHILD_PROCESS_INIT; size_t i; @@ -1175,7 +1184,7 @@ static int push_dav(int nr_spec, char **specs) return 0; } -static int push_git(struct discovery *heads, int nr_spec, char **specs) +static int push_git(struct discovery *heads, int nr_spec, const char **specs) { struct rpc_state rpc; int i, err; @@ -1196,6 +1205,8 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs) argv_array_push(&args, "--signed=yes"); else if (options.push_cert == SEND_PACK_PUSH_CERT_IF_ASKED) argv_array_push(&args, "--signed=if-asked"); + if (options.atomic) + argv_array_push(&args, "--atomic"); if (options.verbosity == 0) argv_array_push(&args, "--quiet"); else if (options.verbosity > 1) @@ -1225,7 +1236,7 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs) return err; } -static int push(int nr_spec, char **specs) +static int push(int nr_spec, const char **specs) { struct discovery *heads = discover_refs("git-receive-pack", 1); int ret; @@ -1240,14 +1251,12 @@ static int push(int nr_spec, char **specs) static void parse_push(struct strbuf *buf) { - char **specs = NULL; - int alloc_spec = 0, nr_spec = 0, i, ret; + struct argv_array specs = ARGV_ARRAY_INIT; + int ret; do { - if (starts_with(buf->buf, "push ")) { - ALLOC_GROW(specs, nr_spec + 1, alloc_spec); - specs[nr_spec++] = xstrdup(buf->buf + 5); - } + if (starts_with(buf->buf, "push ")) + argv_array_push(&specs, buf->buf + 5); else die(_("http transport does not support %s"), buf->buf); @@ -1258,7 +1267,7 @@ static void parse_push(struct strbuf *buf) break; } while (1); - ret = push(nr_spec, specs); + ret = push(specs.argc, specs.argv); printf("\n"); fflush(stdout); @@ -1266,9 +1275,7 @@ static void parse_push(struct strbuf *buf) exit(128); /* error already reported */ free_specs: - for (i = 0; i < nr_spec; i++) - free(specs[i]); - free(specs); + argv_array_clear(&specs); } static int stateless_connect(const char *service_name)