@@ -110,6 +110,7 @@ struct upload_pack_data {
110
110
unsigned done : 1 ; /* v2 only */
111
111
unsigned allow_ref_in_want : 1 ; /* v2 only */
112
112
unsigned allow_sideband_all : 1 ; /* v2 only */
113
+ unsigned advertise_sid : 1 ;
113
114
};
114
115
115
116
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)
141
142
packet_writer_init (& data -> writer , 1 );
142
143
143
144
data -> keepalive = 5 ;
145
+ data -> advertise_sid = 0 ;
144
146
}
145
147
146
148
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)
1178
1180
strbuf_addf (buf , " symref=%s:%s" , item -> string , (char * )item -> util );
1179
1181
}
1180
1182
1183
+ static void format_session_id (struct strbuf * buf , struct upload_pack_data * d ) {
1184
+ if (d -> advertise_sid )
1185
+ strbuf_addf (buf , " session-id=%s" , trace2_session_id ());
1186
+ }
1187
+
1181
1188
static int send_ref (const char * refname , const struct object_id * oid ,
1182
1189
int flag , void * cb_data )
1183
1190
{
@@ -1193,9 +1200,11 @@ static int send_ref(const char *refname, const struct object_id *oid,
1193
1200
1194
1201
if (capabilities ) {
1195
1202
struct strbuf symref_info = STRBUF_INIT ;
1203
+ struct strbuf session_id = STRBUF_INIT ;
1196
1204
1197
1205
format_symref_info (& symref_info , & data -> symref );
1198
- packet_write_fmt (1 , "%s %s%c%s%s%s%s%s%s object-format=%s agent=%s\n" ,
1206
+ format_session_id (& session_id , data );
1207
+ packet_write_fmt (1 , "%s %s%c%s%s%s%s%s%s%s object-format=%s agent=%s\n" ,
1199
1208
oid_to_hex (oid ), refname_nons ,
1200
1209
0 , capabilities ,
1201
1210
(data -> allow_uor & ALLOW_TIP_SHA1 ) ?
@@ -1205,9 +1214,11 @@ static int send_ref(const char *refname, const struct object_id *oid,
1205
1214
data -> stateless_rpc ? " no-done" : "" ,
1206
1215
symref_info .buf ,
1207
1216
data -> allow_filter ? " filter" : "" ,
1217
+ session_id .buf ,
1208
1218
the_hash_algo -> name ,
1209
1219
git_user_agent_sanitized ());
1210
1220
strbuf_release (& symref_info );
1221
+ strbuf_release (& session_id );
1211
1222
} else {
1212
1223
packet_write_fmt (1 , "%s %s\n" , oid_to_hex (oid ), refname_nons );
1213
1224
}
@@ -1299,6 +1310,8 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data)
1299
1310
data -> allow_sideband_all = git_config_bool (var , value );
1300
1311
} else if (!strcmp ("core.precomposeunicode" , var )) {
1301
1312
precomposed_unicode = git_config_bool (var , value );
1313
+ } else if (!strcmp ("transfer.advertisesid" , var )) {
1314
+ data -> advertise_sid = git_config_bool (var , value );
1302
1315
}
1303
1316
1304
1317
if (current_config_scope () != CONFIG_SCOPE_LOCAL &&
0 commit comments