@@ -1213,43 +1213,50 @@ static int add_haves(struct fetch_negotiator *negotiator,
1213
1213
return haves_added ;
1214
1214
}
1215
1215
1216
- static int send_fetch_request (struct fetch_negotiator * negotiator , int fd_out ,
1217
- struct fetch_pack_args * args ,
1218
- const struct ref * wants , struct oidset * common ,
1219
- int * haves_to_send , int * in_vain ,
1220
- int sideband_all , int seen_ack )
1216
+ static void write_fetch_command_and_capabilities (struct strbuf * req_buf ,
1217
+ const struct string_list * server_options )
1221
1218
{
1222
- int haves_added ;
1223
- int done_sent = 0 ;
1224
1219
const char * hash_name ;
1225
- struct strbuf req_buf = STRBUF_INIT ;
1226
1220
1227
1221
if (server_supports_v2 ("fetch" , 1 ))
1228
- packet_buf_write (& req_buf , "command=fetch" );
1222
+ packet_buf_write (req_buf , "command=fetch" );
1229
1223
if (server_supports_v2 ("agent" , 0 ))
1230
- packet_buf_write (& req_buf , "agent=%s" , git_user_agent_sanitized ());
1224
+ packet_buf_write (req_buf , "agent=%s" , git_user_agent_sanitized ());
1231
1225
if (advertise_sid && server_supports_v2 ("session-id" , 0 ))
1232
- packet_buf_write (& req_buf , "session-id=%s" , trace2_session_id ());
1233
- if (args -> server_options && args -> server_options -> nr &&
1226
+ packet_buf_write (req_buf , "session-id=%s" , trace2_session_id ());
1227
+ if (server_options && server_options -> nr &&
1234
1228
server_supports_v2 ("server-option" , 1 )) {
1235
1229
int i ;
1236
- for (i = 0 ; i < args -> server_options -> nr ; i ++ )
1237
- packet_buf_write (& req_buf , "server-option=%s" ,
1238
- args -> server_options -> items [i ].string );
1230
+ for (i = 0 ; i < server_options -> nr ; i ++ )
1231
+ packet_buf_write (req_buf , "server-option=%s" ,
1232
+ server_options -> items [i ].string );
1239
1233
}
1240
1234
1241
1235
if (server_feature_v2 ("object-format" , & hash_name )) {
1242
1236
int hash_algo = hash_algo_by_name (hash_name );
1243
1237
if (hash_algo_by_ptr (the_hash_algo ) != hash_algo )
1244
1238
die (_ ("mismatched algorithms: client %s; server %s" ),
1245
1239
the_hash_algo -> name , hash_name );
1246
- packet_buf_write (& req_buf , "object-format=%s" , the_hash_algo -> name );
1240
+ packet_buf_write (req_buf , "object-format=%s" , the_hash_algo -> name );
1247
1241
} else if (hash_algo_by_ptr (the_hash_algo ) != GIT_HASH_SHA1 ) {
1248
1242
die (_ ("the server does not support algorithm '%s'" ),
1249
1243
the_hash_algo -> name );
1250
1244
}
1245
+ packet_buf_delim (req_buf );
1246
+ }
1247
+
1248
+ static int send_fetch_request (struct fetch_negotiator * negotiator , int fd_out ,
1249
+ struct fetch_pack_args * args ,
1250
+ const struct ref * wants , struct oidset * common ,
1251
+ int * haves_to_send , int * in_vain ,
1252
+ int sideband_all , int seen_ack )
1253
+ {
1254
+ int haves_added ;
1255
+ int done_sent = 0 ;
1256
+ struct strbuf req_buf = STRBUF_INIT ;
1257
+
1258
+ write_fetch_command_and_capabilities (& req_buf , args -> server_options );
1251
1259
1252
- packet_buf_delim (& req_buf );
1253
1260
if (args -> use_thin_pack )
1254
1261
packet_buf_write (& req_buf , "thin-pack" );
1255
1262
if (args -> no_progress )
0 commit comments