Skip to content

Commit 1b70fe5

Browse files
rsahlberggitster
authored andcommitted
receive-pack.c: negotiate atomic push support
This adds the atomic protocol option to allow receive-pack to inform the client that it has atomic push capability. This commit makes the functionality introduced in the previous commits go live for the serving side. The changes in documentation reflect the protocol capabilities of the server. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68deed2 commit 1b70fe5

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

Documentation/technical/protocol-capabilities.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ was sent. Server MUST NOT ignore capabilities that client requested
1818
and server advertised. As a consequence of these rules, server MUST
1919
NOT advertise capabilities it does not understand.
2020

21-
The 'report-status', 'delete-refs', 'quiet', and 'push-cert' capabilities
22-
are sent and recognized by the receive-pack (push to server) process.
21+
The 'atomic', 'report-status', 'delete-refs', 'quiet', and 'push-cert'
22+
capabilities are sent and recognized by the receive-pack (push to server)
23+
process.
2324

2425
The 'ofs-delta' and 'side-band-64k' capabilities are sent and recognized
2526
by both upload-pack and receive-pack protocols. The 'agent' capability
@@ -244,6 +245,14 @@ respond with the 'quiet' capability to suppress server-side progress
244245
reporting if the local progress reporting is also being suppressed
245246
(e.g., via `push -q`, or if stderr does not go to a tty).
246247

248+
atomic
249+
------
250+
251+
If the server sends the 'atomic' capability it is capable of accepting
252+
atomic pushes. If the pushing client requests this capability, the server
253+
will update the refs in one atomic transaction. Either all refs are
254+
updated or none.
255+
247256
allow-tip-sha1-in-want
248257
----------------------
249258

builtin/receive-pack.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static int receive_fsck_objects = -1;
3737
static int transfer_fsck_objects = -1;
3838
static int receive_unpack_limit = -1;
3939
static int transfer_unpack_limit = -1;
40+
static int advertise_atomic_push = 1;
4041
static int unpack_limit = 100;
4142
static int report_status;
4243
static int use_sideband;
@@ -159,6 +160,11 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
159160
return 0;
160161
}
161162

163+
if (strcmp(var, "receive.advertiseatomic") == 0) {
164+
advertise_atomic_push = git_config_bool(var, value);
165+
return 0;
166+
}
167+
162168
return git_default_config(var, value, cb);
163169
}
164170

@@ -174,6 +180,8 @@ static void show_ref(const char *path, const unsigned char *sha1)
174180

175181
strbuf_addstr(&cap,
176182
"report-status delete-refs side-band-64k quiet");
183+
if (advertise_atomic_push)
184+
strbuf_addstr(&cap, " atomic");
177185
if (prefer_ofs_delta)
178186
strbuf_addstr(&cap, " ofs-delta");
179187
if (push_cert_nonce)
@@ -1263,6 +1271,9 @@ static struct command *read_head_info(struct sha1_array *shallow)
12631271
use_sideband = LARGE_PACKET_MAX;
12641272
if (parse_feature_request(feature_list, "quiet"))
12651273
quiet = 1;
1274+
if (advertise_atomic_push
1275+
&& parse_feature_request(feature_list, "atomic"))
1276+
use_atomic = 1;
12661277
}
12671278

12681279
if (!strcmp(line, "push-cert")) {

0 commit comments

Comments
 (0)