From 3bca1e7f9f9708b970035a641d21f8c5cec1cd88 Mon Sep 17 00:00:00 2001 From: Emily Shaffer Date: Thu, 11 Jul 2019 14:19:19 -0700 Subject: transport-helper: enforce atomic in push_refs_with_push Teach transport-helper how to notice if skipping a ref during push would violate atomicity on the client side. We notice that a ref would be rejected, and choose not to send it, but don't notice that if the client has asked for --atomic we are violating atomicity if all the other pushes we are sending would succeed. Asking the server end to uphold atomicity wouldn't work here as the server doesn't have any idea that we tried to update a ref that's broken. The added test-case is a succinct way to reproduce this issue that fails today. The same steps work fine when we aren't using a transport-helper to get to the upstream, i.e. when we've added a local repository as a remote: git remote add ~/upstream upstream Signed-off-by: Emily Shaffer Signed-off-by: Junio C Hamano --- transport-helper.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'transport-helper.c') diff --git a/transport-helper.c b/transport-helper.c index cec83bd663..b11abd291c 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -853,6 +853,7 @@ static int push_refs_with_push(struct transport *transport, { int force_all = flags & TRANSPORT_PUSH_FORCE; int mirror = flags & TRANSPORT_PUSH_MIRROR; + int atomic = flags & TRANSPORT_PUSH_ATOMIC; struct helper_data *data = transport->data; struct strbuf buf = STRBUF_INIT; struct ref *ref; @@ -872,6 +873,11 @@ static int push_refs_with_push(struct transport *transport, case REF_STATUS_REJECT_NONFASTFORWARD: case REF_STATUS_REJECT_STALE: case REF_STATUS_REJECT_ALREADY_EXISTS: + if (atomic) { + string_list_clear(&cas_options, 0); + return 0; + } else + continue; case REF_STATUS_UPTODATE: continue; default: -- cgit v1.2.3