upload-pack: advertise session ID in v0 capabilities
When transfer.advertiseSID is true, advertise upload-pack's session ID via the new session-id capability. Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e97e1cf464
commit
791e1adf22
@ -110,6 +110,7 @@ struct upload_pack_data {
|
|||||||
unsigned done : 1; /* v2 only */
|
unsigned done : 1; /* v2 only */
|
||||||
unsigned allow_ref_in_want : 1; /* v2 only */
|
unsigned allow_ref_in_want : 1; /* v2 only */
|
||||||
unsigned allow_sideband_all : 1; /* v2 only */
|
unsigned allow_sideband_all : 1; /* v2 only */
|
||||||
|
unsigned advertise_sid : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void upload_pack_data_init(struct upload_pack_data *data)
|
static void upload_pack_data_init(struct upload_pack_data *data)
|
||||||
@ -141,6 +142,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
|
|||||||
packet_writer_init(&data->writer, 1);
|
packet_writer_init(&data->writer, 1);
|
||||||
|
|
||||||
data->keepalive = 5;
|
data->keepalive = 5;
|
||||||
|
data->advertise_sid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void upload_pack_data_clear(struct upload_pack_data *data)
|
static void upload_pack_data_clear(struct upload_pack_data *data)
|
||||||
@ -1178,6 +1180,11 @@ static void format_symref_info(struct strbuf *buf, struct string_list *symref)
|
|||||||
strbuf_addf(buf, " symref=%s:%s", item->string, (char *)item->util);
|
strbuf_addf(buf, " symref=%s:%s", item->string, (char *)item->util);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void format_session_id(struct strbuf *buf, struct upload_pack_data *d) {
|
||||||
|
if (d->advertise_sid)
|
||||||
|
strbuf_addf(buf, " session-id=%s", trace2_session_id());
|
||||||
|
}
|
||||||
|
|
||||||
static int send_ref(const char *refname, const struct object_id *oid,
|
static int send_ref(const char *refname, const struct object_id *oid,
|
||||||
int flag, void *cb_data)
|
int flag, void *cb_data)
|
||||||
{
|
{
|
||||||
@ -1193,9 +1200,11 @@ static int send_ref(const char *refname, const struct object_id *oid,
|
|||||||
|
|
||||||
if (capabilities) {
|
if (capabilities) {
|
||||||
struct strbuf symref_info = STRBUF_INIT;
|
struct strbuf symref_info = STRBUF_INIT;
|
||||||
|
struct strbuf session_id = STRBUF_INIT;
|
||||||
|
|
||||||
format_symref_info(&symref_info, &data->symref);
|
format_symref_info(&symref_info, &data->symref);
|
||||||
packet_write_fmt(1, "%s %s%c%s%s%s%s%s%s object-format=%s agent=%s\n",
|
format_session_id(&session_id, data);
|
||||||
|
packet_write_fmt(1, "%s %s%c%s%s%s%s%s%s%s object-format=%s agent=%s\n",
|
||||||
oid_to_hex(oid), refname_nons,
|
oid_to_hex(oid), refname_nons,
|
||||||
0, capabilities,
|
0, capabilities,
|
||||||
(data->allow_uor & ALLOW_TIP_SHA1) ?
|
(data->allow_uor & ALLOW_TIP_SHA1) ?
|
||||||
@ -1205,9 +1214,11 @@ static int send_ref(const char *refname, const struct object_id *oid,
|
|||||||
data->stateless_rpc ? " no-done" : "",
|
data->stateless_rpc ? " no-done" : "",
|
||||||
symref_info.buf,
|
symref_info.buf,
|
||||||
data->allow_filter ? " filter" : "",
|
data->allow_filter ? " filter" : "",
|
||||||
|
session_id.buf,
|
||||||
the_hash_algo->name,
|
the_hash_algo->name,
|
||||||
git_user_agent_sanitized());
|
git_user_agent_sanitized());
|
||||||
strbuf_release(&symref_info);
|
strbuf_release(&symref_info);
|
||||||
|
strbuf_release(&session_id);
|
||||||
} else {
|
} else {
|
||||||
packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons);
|
packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons);
|
||||||
}
|
}
|
||||||
@ -1299,6 +1310,8 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data)
|
|||||||
data->allow_sideband_all = git_config_bool(var, value);
|
data->allow_sideband_all = git_config_bool(var, value);
|
||||||
} else if (!strcmp("core.precomposeunicode", var)) {
|
} else if (!strcmp("core.precomposeunicode", var)) {
|
||||||
precomposed_unicode = git_config_bool(var, value);
|
precomposed_unicode = git_config_bool(var, value);
|
||||||
|
} else if (!strcmp("transfer.advertisesid", var)) {
|
||||||
|
data->advertise_sid = git_config_bool(var, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_config_scope() != CONFIG_SCOPE_LOCAL &&
|
if (current_config_scope() != CONFIG_SCOPE_LOCAL &&
|
||||||
|
Loading…
Reference in New Issue
Block a user