send-pack: advertise session ID in capabilities

When the server sent a session-id capability and transfer.advertiseSID is true, advertise send-pack's own session ID back to the server. Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Josh Steadmon committed Nov 11, 2020 at 15:29 UTC 8c4870029dd084bc030e1b5383fa13358bcce236
1 file changed +7
send-pack.c
+7
@@ -424,6 +424,7 @@ int send_pack(struct send_pack_args *args,
424 int use_sideband = 0;
425 int quiet_supported = 0;
426 int agent_supported = 0;
427 + int advertise_sid = 0;
428 int use_atomic = 0;
429 int atomic_supported = 0;
430 int use_push_options = 0;
@@ -435,6 +436,8 @@ int send_pack(struct send_pack_args *args,
436 const char *push_cert_nonce = NULL;
437 struct packet_reader reader;
438
439 + git_config_get_bool("transfer.advertisesid", &advertise_sid);
440 +
441 /* Does the other end support the reporting? */
442 if (server_supports("report-status-v2"))
443 status_report = 2;
@@ -450,6 +453,8 @@ int send_pack(struct send_pack_args *args,
453 quiet_supported = 1;
454 if (server_supports("agent"))
455 agent_supported = 1;
456 + if (!server_supports("session-id"))
457 + advertise_sid = 0;
458 if (server_supports("no-thin"))
459 args->use_thin_pack = 0;
460 if (server_supports("atomic"))
@@ -506,6 +511,8 @@ int send_pack(struct send_pack_args *args,
511 strbuf_addf(&cap_buf, " object-format=%s", the_hash_algo->name);
512 if (agent_supported)
513 strbuf_addf(&cap_buf, " agent=%s", git_user_agent_sanitized());
514 + if (advertise_sid)
515 + strbuf_addf(&cap_buf, " session-id=%s", trace2_session_id());
516
517 /*
518 * NEEDSWORK: why does delete-refs have to be so specific to