@@ -1351,56 +1351,29 @@ static int process_section_header(struct packet_reader *reader,
1351
1351
return ret ;
1352
1352
}
1353
1353
1354
- enum common_found {
1355
- /*
1356
- * No commit was found to be possessed by both the client and the
1357
- * server, and "ready" was not received.
1358
- */
1359
- NO_COMMON_FOUND ,
1360
-
1361
- /*
1362
- * At least one commit was found to be possessed by both the client and
1363
- * the server, and "ready" was not received.
1364
- */
1365
- COMMON_FOUND ,
1366
-
1367
- /*
1368
- * "ready" was received, indicating that the server is ready to send
1369
- * the packfile without any further negotiation.
1370
- */
1371
- READY
1372
- };
1373
-
1374
- static enum common_found process_acks (struct fetch_negotiator * negotiator ,
1375
- struct packet_reader * reader ,
1376
- struct oidset * common )
1354
+ static int process_ack (struct fetch_negotiator * negotiator ,
1355
+ struct packet_reader * reader ,
1356
+ struct object_id * common_oid ,
1357
+ int * received_ready )
1377
1358
{
1378
- /* received */
1379
- int received_ready = 0 ;
1380
- int received_ack = 0 ;
1381
-
1382
- process_section_header (reader , "acknowledgments" , 0 );
1383
1359
while (packet_reader_read (reader ) == PACKET_READ_NORMAL ) {
1384
1360
const char * arg ;
1385
1361
1386
1362
if (!strcmp (reader -> line , "NAK" ))
1387
1363
continue ;
1388
1364
1389
1365
if (skip_prefix (reader -> line , "ACK " , & arg )) {
1390
- struct object_id oid ;
1391
- received_ack = 1 ;
1392
- if (!get_oid_hex (arg , & oid )) {
1366
+ if (!get_oid_hex (arg , common_oid )) {
1393
1367
struct commit * commit ;
1394
- oidset_insert (common , & oid );
1395
- commit = lookup_commit (the_repository , & oid );
1368
+ commit = lookup_commit (the_repository , common_oid );
1396
1369
if (negotiator )
1397
1370
negotiator -> ack (negotiator , commit );
1398
1371
}
1399
- continue ;
1372
+ return 1 ;
1400
1373
}
1401
1374
1402
1375
if (!strcmp (reader -> line , "ready" )) {
1403
- received_ready = 1 ;
1376
+ * received_ready = 1 ;
1404
1377
continue ;
1405
1378
}
1406
1379
@@ -1418,13 +1391,12 @@ static enum common_found process_acks(struct fetch_negotiator *negotiator,
1418
1391
* sent. Therefore, a DELIM is expected if "ready" is sent, and a FLUSH
1419
1392
* otherwise.
1420
1393
*/
1421
- if (received_ready && reader -> status != PACKET_READ_DELIM )
1394
+ if (* received_ready && reader -> status != PACKET_READ_DELIM )
1422
1395
die (_ ("expected packfile to be sent after 'ready'" ));
1423
- if (!received_ready && reader -> status != PACKET_READ_FLUSH )
1396
+ if (!* received_ready && reader -> status != PACKET_READ_FLUSH )
1424
1397
die (_ ("expected no other sections to be sent after no 'ready'" ));
1425
1398
1426
- return received_ready ? READY :
1427
- (received_ack ? COMMON_FOUND : NO_COMMON_FOUND );
1399
+ return 0 ;
1428
1400
}
1429
1401
1430
1402
static void receive_shallow_info (struct fetch_pack_args * args ,
@@ -1573,6 +1545,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1573
1545
struct fetch_negotiator negotiator_alloc ;
1574
1546
struct fetch_negotiator * negotiator ;
1575
1547
int seen_ack = 0 ;
1548
+ struct object_id common_oid ;
1549
+ int received_ready = 0 ;
1576
1550
struct string_list packfile_uris = STRING_LIST_INIT_DUP ;
1577
1551
int i ;
1578
1552
struct strvec index_pack_args = STRVEC_INIT ;
@@ -1631,22 +1605,22 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1631
1605
break ;
1632
1606
case FETCH_PROCESS_ACKS :
1633
1607
/* Process ACKs/NAKs */
1634
- switch (process_acks (negotiator , & reader , & common )) {
1635
- case READY :
1608
+ process_section_header (& reader , "acknowledgments" , 0 );
1609
+ while (process_ack (negotiator , & reader , & common_oid ,
1610
+ & received_ready )) {
1611
+ in_vain = 0 ;
1612
+ seen_ack = 1 ;
1613
+ oidset_insert (& common , & common_oid );
1614
+ }
1615
+ if (received_ready ) {
1636
1616
/*
1637
1617
* Don't check for response delimiter; get_pack() will
1638
1618
* read the rest of this response.
1639
1619
*/
1640
1620
state = FETCH_GET_PACK ;
1641
- break ;
1642
- case COMMON_FOUND :
1643
- in_vain = 0 ;
1644
- seen_ack = 1 ;
1645
- /* fallthrough */
1646
- case NO_COMMON_FOUND :
1621
+ } else {
1647
1622
do_check_stateless_delimiter (args , & reader );
1648
1623
state = FETCH_SEND_REQUEST ;
1649
- break ;
1650
1624
}
1651
1625
break ;
1652
1626
case FETCH_GET_PACK :
0 commit comments