| 1377 | } |
| 1378 | |
| 1379 | static void write_fetch_command_and_capabilities(struct strbuf *req_buf, |
| 1380 | const struct string_list *server_options) |
| 1381 | { |
| 1382 | const char *hash_name; |
| 1383 | |
| 1384 | ensure_server_supports_v2("fetch"); |
| 1385 | packet_buf_write(req_buf, "command=fetch"); |
| 1386 | if (server_supports_v2("agent")) |
| 1387 | packet_buf_write(req_buf, "agent=%s", git_user_agent_sanitized()); |
| 1388 | if (advertise_sid && server_supports_v2("session-id")) |
| 1389 | packet_buf_write(req_buf, "session-id=%s", trace2_session_id()); |
| 1390 | if (server_options && server_options->nr) { |
| 1391 | int i; |
| 1392 | ensure_server_supports_v2("server-option"); |
| 1393 | for (i = 0; i < server_options->nr; i++) |
| 1394 | packet_buf_write(req_buf, "server-option=%s", |
| 1395 | server_options->items[i].string); |
| 1396 | } |
| 1397 | |
| 1398 | if (server_feature_v2("object-format", &hash_name)) { |
| 1399 | int hash_algo = hash_algo_by_name(hash_name); |
| 1400 | if (hash_algo_by_ptr(the_hash_algo) != hash_algo) |
| 1401 | die(_("mismatched algorithms: client %s; server %s"), |
| 1402 | the_hash_algo->name, hash_name); |
| 1403 | packet_buf_write(req_buf, "object-format=%s", the_hash_algo->name); |
| 1404 | } else if (hash_algo_by_ptr(the_hash_algo) != GIT_HASH_SHA1_LEGACY) { |
| 1405 | die(_("the server does not support algorithm '%s'"), |
| 1406 | the_hash_algo->name); |
| 1407 | } |
| 1408 | packet_buf_delim(req_buf); |
| 1409 | } |
| 1410 | |
| 1411 | static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out, |
| 1412 | struct fetch_pack_args *args, |
no test coverage detected