@@ -1213,43 +1213,50 @@ static int add_haves(struct fetch_negotiator *negotiator,
12131213 return haves_added ;
12141214}
12151215
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 )
12211218{
1222- int haves_added ;
1223- int done_sent = 0 ;
12241219 const char * hash_name ;
1225- struct strbuf req_buf = STRBUF_INIT ;
12261220
12271221 if (server_supports_v2 ("fetch" , 1 ))
1228- packet_buf_write (& req_buf , "command=fetch" );
1222+ packet_buf_write (req_buf , "command=fetch" );
12291223 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 ());
12311225 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 &&
12341228 server_supports_v2 ("server-option" , 1 )) {
12351229 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 );
12391233 }
12401234
12411235 if (server_feature_v2 ("object-format" , & hash_name )) {
12421236 int hash_algo = hash_algo_by_name (hash_name );
12431237 if (hash_algo_by_ptr (the_hash_algo ) != hash_algo )
12441238 die (_ ("mismatched algorithms: client %s; server %s" ),
12451239 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 );
12471241 } else if (hash_algo_by_ptr (the_hash_algo ) != GIT_HASH_SHA1 ) {
12481242 die (_ ("the server does not support algorithm '%s'" ),
12491243 the_hash_algo -> name );
12501244 }
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 );
12511259
1252- packet_buf_delim (& req_buf );
12531260 if (args -> use_thin_pack )
12541261 packet_buf_write (& req_buf , "thin-pack" );
12551262 if (args -> no_progress )
0 commit comments