@@ -35,6 +35,7 @@ static int fetch_fsck_objects = -1;
3535static int transfer_fsck_objects = -1 ;
3636static int agent_supported ;
3737static int server_supports_filtering ;
38+ static int advertise_sid ;
3839static struct shallow_lock shallow_lock ;
3940static const char * alternate_shallow_file ;
4041static struct strbuf fsck_msg_types = STRBUF_INIT ;
@@ -326,6 +327,8 @@ static int find_common(struct fetch_negotiator *negotiator,
326327 if (deepen_not_ok ) strbuf_addstr (& c , " deepen-not" );
327328 if (agent_supported ) strbuf_addf (& c , " agent=%s" ,
328329 git_user_agent_sanitized ());
330+ if (advertise_sid )
331+ strbuf_addf (& c , " session-id=%s" , trace2_session_id ());
329332 if (args -> filter_options .choice )
330333 strbuf_addstr (& c , " filter" );
331334 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,
979982 agent_len , agent_feature );
980983 }
981984
985+ if (!server_supports ("session-id" ))
986+ advertise_sid = 0 ;
987+
982988 if (server_supports ("shallow" ))
983989 print_verbose (args , _ ("Server supports %s" ), "shallow" );
984990 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,
11911197 packet_buf_write (& req_buf , "command=fetch" );
11921198 if (server_supports_v2 ("agent" , 0 ))
11931199 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 ());
11941202 if (args -> server_options && args -> server_options -> nr &&
11951203 server_supports_v2 ("server-option" , 1 )) {
11961204 int i ;
@@ -1711,6 +1719,7 @@ static void fetch_pack_config(void)
17111719 git_config_get_bool ("repack.usedeltabaseoffset" , & prefer_ofs_delta );
17121720 git_config_get_bool ("fetch.fsckobjects" , & fetch_fsck_objects );
17131721 git_config_get_bool ("transfer.fsckobjects" , & transfer_fsck_objects );
1722+ git_config_get_bool ("transfer.advertisesid" , & advertise_sid );
17141723 if (!uri_protocols .nr ) {
17151724 char * str ;
17161725
0 commit comments