@@ -35,6 +35,7 @@ static int fetch_fsck_objects = -1;
35
35
static int transfer_fsck_objects = -1 ;
36
36
static int agent_supported ;
37
37
static int server_supports_filtering ;
38
+ static int advertise_sid ;
38
39
static struct shallow_lock shallow_lock ;
39
40
static const char * alternate_shallow_file ;
40
41
static struct strbuf fsck_msg_types = STRBUF_INIT ;
@@ -326,6 +327,8 @@ static int find_common(struct fetch_negotiator *negotiator,
326
327
if (deepen_not_ok ) strbuf_addstr (& c , " deepen-not" );
327
328
if (agent_supported ) strbuf_addf (& c , " agent=%s" ,
328
329
git_user_agent_sanitized ());
330
+ if (advertise_sid )
331
+ strbuf_addf (& c , " session-id=%s" , trace2_session_id ());
329
332
if (args -> filter_options .choice )
330
333
strbuf_addstr (& c , " filter" );
331
334
packet_buf_write (& req_buf , "want %s%s\n" , remote_hex , c .buf );
@@ -979,6 +982,9 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
979
982
agent_len , agent_feature );
980
983
}
981
984
985
+ if (!server_supports ("session-id" ))
986
+ advertise_sid = 0 ;
987
+
982
988
if (server_supports ("shallow" ))
983
989
print_verbose (args , _ ("Server supports %s" ), "shallow" );
984
990
else if (args -> depth > 0 || is_repository_shallow (r ))
@@ -1191,6 +1197,8 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
1191
1197
packet_buf_write (& req_buf , "command=fetch" );
1192
1198
if (server_supports_v2 ("agent" , 0 ))
1193
1199
packet_buf_write (& req_buf , "agent=%s" , git_user_agent_sanitized ());
1200
+ if (advertise_sid && server_supports_v2 ("session-id" , 0 ))
1201
+ packet_buf_write (& req_buf , "session-id=%s" , trace2_session_id ());
1194
1202
if (args -> server_options && args -> server_options -> nr &&
1195
1203
server_supports_v2 ("server-option" , 1 )) {
1196
1204
int i ;
@@ -1711,6 +1719,7 @@ static void fetch_pack_config(void)
1711
1719
git_config_get_bool ("repack.usedeltabaseoffset" , & prefer_ofs_delta );
1712
1720
git_config_get_bool ("fetch.fsckobjects" , & fetch_fsck_objects );
1713
1721
git_config_get_bool ("transfer.fsckobjects" , & transfer_fsck_objects );
1722
+ git_config_get_bool ("transfer.advertisesid" , & advertise_sid );
1714
1723
if (!uri_protocols .nr ) {
1715
1724
char * str ;
1716
1725
0 commit comments