| 1399 | } |
| 1400 | |
| 1401 | void upload_pack(const int advertise_refs, const int stateless_rpc, |
| 1402 | const int timeout) |
| 1403 | { |
| 1404 | struct packet_reader reader; |
| 1405 | struct upload_pack_data data; |
| 1406 | |
| 1407 | upload_pack_data_init(&data); |
| 1408 | get_upload_pack_config(the_repository, &data); |
| 1409 | |
| 1410 | data.stateless_rpc = stateless_rpc; |
| 1411 | data.timeout = timeout; |
| 1412 | if (data.timeout) |
| 1413 | data.daemon_mode = 1; |
| 1414 | |
| 1415 | refs_head_ref_namespaced(get_main_ref_store(the_repository), |
| 1416 | find_symref, &data.symref); |
| 1417 | |
| 1418 | if (advertise_refs || !data.stateless_rpc) { |
| 1419 | reset_timeout(data.timeout); |
| 1420 | if (advertise_refs) |
| 1421 | data.no_done = 1; |
| 1422 | refs_head_ref_namespaced(get_main_ref_store(the_repository), |
| 1423 | send_ref, &data); |
| 1424 | for_each_namespaced_ref_1(send_ref, &data); |
| 1425 | if (!data.sent_capabilities) { |
| 1426 | struct reference ref = { |
| 1427 | .name = "capabilities^{}", |
| 1428 | .oid = null_oid(the_hash_algo), |
| 1429 | }; |
| 1430 | |
| 1431 | write_v0_ref(&data, &ref, ref.name); |
| 1432 | } |
| 1433 | /* |
| 1434 | * fflush stdout before calling advertise_shallow_grafts because send_ref |
| 1435 | * uses stdio. |
| 1436 | */ |
| 1437 | fflush_or_die(stdout); |
| 1438 | advertise_shallow_grafts(1); |
| 1439 | packet_flush(1); |
| 1440 | } else { |
| 1441 | refs_head_ref_namespaced(get_main_ref_store(the_repository), |
| 1442 | check_ref, &data); |
| 1443 | for_each_namespaced_ref_1(check_ref, &data); |
| 1444 | } |
| 1445 | |
| 1446 | if (!advertise_refs) { |
| 1447 | packet_reader_init(&reader, 0, NULL, 0, |
| 1448 | PACKET_READ_CHOMP_NEWLINE | |
| 1449 | PACKET_READ_DIE_ON_ERR_PACKET); |
| 1450 | |
| 1451 | receive_needs(&data, &reader); |
| 1452 | |
| 1453 | /* |
| 1454 | * An EOF at this exact point in negotiation should be |
| 1455 | * acceptable from stateless clients as they will consume the |
| 1456 | * shallow list before doing subsequent rpc with haves/etc. |
| 1457 | */ |
| 1458 | if (data.stateless_rpc) |
nothing calls this directly
no test coverage detected