path: root/remote-curl.c
diff options
authorbrian m. carlson <>2019-10-16 23:45:34 (GMT)
committerJunio C Hamano <>2019-10-17 07:08:22 (GMT)
commit6f1194246a514ba093a11dde73aabe4c0da5526f (patch)
treec77e309f8c9b926709aeb15bc3a13baa08f149e2 /remote-curl.c
parent5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 (diff)
remote-curl: pass on atomic capability to remote side
When pushing more than one reference with the --atomic option, the server is supposed to perform a single atomic transaction to update the references, leaving them either all to succeed or all to fail. This works fine when pushing locally or over SSH, but when pushing over HTTP, we fail to pass the atomic capability to the remote side. In fact, we have not reported this capability to any remote helpers during the life of the feature. Now normally, things happen to work nevertheless, since we actually check for most types of failures, such as non-fast-forward updates, on the client side, and just abort the entire attempt. However, if the server side reports a problem, such as the inability to lock a ref, the transaction isn't atomic, because we haven't passed the appropriate capability over and the remote side has no way of knowing that we wanted atomic behavior. Fix this by passing the option from the transport code through to remote helpers, and from the HTTP remote helper down to send-pack. With this change, we can detect if the server side rejects the push and report back appropriately. Note the difference in the messages: the remote side reports "atomic transaction failed", while our own checking rejects pushes with the message "atomic push failed". Document the atomic option in the remote helper documentation, so other implementers can implement it if they like. Signed-off-by: brian m. carlson <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'remote-curl.c')
1 files changed, 12 insertions, 1 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 051f266..5232ed8 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)
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);
@@ -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)