Re: [PATCHv2 1/6] receive-pack.c: add protocol support to negotiate atomic-push
From: Junio C Hamano <hidden>
Date: 2016-06-15 23:03:18
Stefan Beller [off-list ref] writes:
quoted hunk
diff --git a/send-pack.c b/send-pack.c index 949cb61..2a513f4 100644 --- a/send-pack.c +++ b/send-pack.c@@ -294,6 +294,8 @@ int send_pack(struct send_pack_args *args, int use_sideband = 0; int quiet_supported = 0; int agent_supported = 0; + int use_atomic; + int atomic_supported = 0; unsigned cmds_sent = 0; int ret; struct async demux;@@ -314,6 +316,8 @@ int send_pack(struct send_pack_args *args, agent_supported = 1; if (server_supports("no-thin")) args->use_thin_pack = 0; + if (server_supports("atomic")) + atomic_supported = 1; if (args->push_cert) { int len;@@ -328,6 +332,11 @@ int send_pack(struct send_pack_args *args, "Perhaps you should specify a branch such as 'master'.\n"); return 0; } + if (args->atomic && !atomic_supported) { + fprintf(stderr, "Server does not support atomic push."); + return -1;
I'd tweak this to
return error("server does not support atomic push.");
to (0) shorten, (1) make sure the message is terminated with LF,
and (2) match the other error messages in the program.
Other than that looks good.
Thanks.
quoted hunk
+ } + use_atomic = atomic_supported && args->atomic; if (status_report) strbuf_addstr(&cap_buf, " report-status");@@ -335,6 +344,8 @@ int send_pack(struct send_pack_args *args, strbuf_addstr(&cap_buf, " side-band-64k"); if (quiet_supported && (args->quiet || !args->progress)) strbuf_addstr(&cap_buf, " quiet"); + if (use_atomic) + strbuf_addstr(&cap_buf, " atomic"); if (agent_supported) strbuf_addf(&cap_buf, " agent=%s", git_user_agent_sanitized());diff --git a/send-pack.h b/send-pack.h index 5635457..b664648 100644 --- a/send-pack.h +++ b/send-pack.h@@ -13,7 +13,8 @@ struct send_pack_args { use_ofs_delta:1, dry_run:1, push_cert:1, - stateless_rpc:1; + stateless_rpc:1, + atomic:1; }; int send_pack(struct send_pack_args *args,