summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/transport.c b/transport.c
index 1fdc7dac1a..7d50c502ad 100644
--- a/transport.c
+++ b/transport.c
@@ -16,7 +16,7 @@
#include "url.h"
#include "submodule.h"
#include "string-list.h"
-#include "sha1-array.h"
+#include "oid-array.h"
#include "sigchain.h"
#include "transport-internal.h"
#include "protocol.h"
@@ -297,7 +297,8 @@ static struct ref *handshake(struct transport *transport, int for_push,
if (must_list_refs)
get_remote_refs(data->fd[1], &reader, &refs, for_push,
ref_prefixes,
- transport->server_options);
+ transport->server_options,
+ transport->stateless_rpc);
break;
case protocol_v1:
case protocol_v0:
@@ -369,24 +370,15 @@ static int fetch_refs_via_pack(struct transport *transport,
refs_tmp = handshake(transport, 0, NULL, must_list_refs);
}
- switch (data->version) {
- case protocol_v2:
- refs = fetch_pack(&args, data->fd,
- refs_tmp ? refs_tmp : transport->remote_refs,
- to_fetch, nr_heads, &data->shallow,
- &transport->pack_lockfile, data->version);
- break;
- case protocol_v1:
- case protocol_v0:
- die_if_server_options(transport);
- refs = fetch_pack(&args, data->fd,
- refs_tmp ? refs_tmp : transport->remote_refs,
- to_fetch, nr_heads, &data->shallow,
- &transport->pack_lockfile, data->version);
- break;
- case protocol_unknown_version:
+ if (data->version == protocol_unknown_version)
BUG("unknown protocol version");
- }
+ else if (data->version <= protocol_v1)
+ die_if_server_options(transport);
+
+ refs = fetch_pack(&args, data->fd,
+ refs_tmp ? refs_tmp : transport->remote_refs,
+ to_fetch, nr_heads, &data->shallow,
+ &transport->pack_lockfile, data->version);
close(data->fd[0]);
close(data->fd[1]);
@@ -715,7 +707,15 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
close(data->fd[1]);
close(data->fd[0]);
- ret |= finish_connect(data->conn);
+ /*
+ * Atomic push may abort the connection early and close the pipe,
+ * which may cause an error for `finish_connect()`. Ignore this error
+ * for atomic git-push.
+ */
+ if (ret || args.atomic)
+ finish_connect(data->conn);
+ else
+ ret = finish_connect(data->conn);
data->conn = NULL;
data->got_remote_heads = 0;
@@ -1240,20 +1240,6 @@ int transport_push(struct repository *r,
err = push_had_errors(remote_refs);
ret = push_ret | err;
- if ((flags & TRANSPORT_PUSH_ATOMIC) && err) {
- struct ref *it;
- for (it = remote_refs; it; it = it->next)
- switch (it->status) {
- case REF_STATUS_NONE:
- case REF_STATUS_UPTODATE:
- case REF_STATUS_OK:
- it->status = REF_STATUS_ATOMIC_PUSH_FAILED;
- break;
- default:
- break;
- }
- }
-
if (!quiet || err)
transport_print_push_status(transport->url, remote_refs,
verbose | porcelain, porcelain,