summaryrefslogtreecommitdiffstats
path: root/send-pack.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2016-07-14 14:49:47 -0700
committerJunio C Hamano <gitster@pobox.com>2016-07-14 15:50:41 -0700
commitf6a4e61fbb647928d615a0befaec163a5d2bf4af (patch)
treee7a2625a11ec28300e33e3ceeae7ddaca3665944 /send-pack.c
parentc714e45f87301562b940e3621431ed7f7fbd16e5 (diff)
downloadgit-f6a4e61fbb647928d615a0befaec163a5d2bf4af.tar.gz
git-f6a4e61fbb647928d615a0befaec163a5d2bf4af.tar.xz
push: accept push options
This implements everything that is required on the client side to make use of push options from the porcelain push command. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'send-pack.c')
-rw-r--r--send-pack.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/send-pack.c b/send-pack.c
index 299d30384..3a842ac2d 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -260,6 +260,7 @@ static int generate_push_cert(struct strbuf *req_buf,
const char *push_cert_nonce)
{
const struct ref *ref;
+ struct string_list_item *item;
char *signing_key = xstrdup(get_signing_key());
const char *cp, *np;
struct strbuf cert = STRBUF_INIT;
@@ -276,6 +277,9 @@ static int generate_push_cert(struct strbuf *req_buf,
}
if (push_cert_nonce[0])
strbuf_addf(&cert, "nonce %s\n", push_cert_nonce);
+ if (args->push_options)
+ for_each_string_list_item(item, args->push_options)
+ strbuf_addf(&cert, "push-option %s\n", item->string);
strbuf_addstr(&cert, "\n");
for (ref = remote_refs; ref; ref = ref->next) {
@@ -370,6 +374,8 @@ int send_pack(struct send_pack_args *args,
int agent_supported = 0;
int use_atomic = 0;
int atomic_supported = 0;
+ int use_push_options = 0;
+ int push_options_supported = 0;
unsigned cmds_sent = 0;
int ret;
struct async demux;
@@ -392,6 +398,8 @@ int send_pack(struct send_pack_args *args,
args->use_thin_pack = 0;
if (server_supports("atomic"))
atomic_supported = 1;
+ if (server_supports("push-options"))
+ push_options_supported = 1;
if (args->push_cert != SEND_PACK_PUSH_CERT_NEVER) {
int len;
@@ -418,6 +426,11 @@ int send_pack(struct send_pack_args *args,
use_atomic = atomic_supported && args->atomic;
+ if (args->push_options && !push_options_supported)
+ die(_("the receiving end does not support push options"));
+
+ use_push_options = push_options_supported && args->push_options;
+
if (status_report)
strbuf_addstr(&cap_buf, " report-status");
if (use_sideband)
@@ -426,6 +439,8 @@ int send_pack(struct send_pack_args *args,
strbuf_addstr(&cap_buf, " quiet");
if (use_atomic)
strbuf_addstr(&cap_buf, " atomic");
+ if (use_push_options)
+ strbuf_addstr(&cap_buf, " push-options");
if (agent_supported)
strbuf_addf(&cap_buf, " agent=%s", git_user_agent_sanitized());
@@ -512,6 +527,18 @@ int send_pack(struct send_pack_args *args,
strbuf_release(&req_buf);
strbuf_release(&cap_buf);
+ if (use_push_options) {
+ struct string_list_item *item;
+ struct strbuf sb = STRBUF_INIT;
+
+ for_each_string_list_item(item, args->push_options)
+ packet_buf_write(&sb, "%s", item->string);
+
+ write_or_die(out, sb.buf, sb.len);
+ packet_flush(out);
+ strbuf_release(&sb);
+ }
+
if (use_sideband && cmds_sent) {
memset(&demux, 0, sizeof(demux));
demux.proc = sideband_demux;