@@ -1351,56 +1351,29 @@ static int process_section_header(struct packet_reader *reader,
13511351 return ret ;
13521352}
13531353
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 )
13771358{
1378- /* received */
1379- int received_ready = 0 ;
1380- int received_ack = 0 ;
1381-
1382- process_section_header (reader , "acknowledgments" , 0 );
13831359 while (packet_reader_read (reader ) == PACKET_READ_NORMAL ) {
13841360 const char * arg ;
13851361
13861362 if (!strcmp (reader -> line , "NAK" ))
13871363 continue ;
13881364
13891365 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 )) {
13931367 struct commit * commit ;
1394- oidset_insert (common , & oid );
1395- commit = lookup_commit (the_repository , & oid );
1368+ commit = lookup_commit (the_repository , common_oid );
13961369 if (negotiator )
13971370 negotiator -> ack (negotiator , commit );
13981371 }
1399- continue ;
1372+ return 1 ;
14001373 }
14011374
14021375 if (!strcmp (reader -> line , "ready" )) {
1403- received_ready = 1 ;
1376+ * received_ready = 1 ;
14041377 continue ;
14051378 }
14061379
@@ -1418,13 +1391,12 @@ static enum common_found process_acks(struct fetch_negotiator *negotiator,
14181391 * sent. Therefore, a DELIM is expected if "ready" is sent, and a FLUSH
14191392 * otherwise.
14201393 */
1421- if (received_ready && reader -> status != PACKET_READ_DELIM )
1394+ if (* received_ready && reader -> status != PACKET_READ_DELIM )
14221395 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 )
14241397 die (_ ("expected no other sections to be sent after no 'ready'" ));
14251398
1426- return received_ready ? READY :
1427- (received_ack ? COMMON_FOUND : NO_COMMON_FOUND );
1399+ return 0 ;
14281400}
14291401
14301402static 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,
15731545 struct fetch_negotiator negotiator_alloc ;
15741546 struct fetch_negotiator * negotiator ;
15751547 int seen_ack = 0 ;
1548+ struct object_id common_oid ;
1549+ int received_ready = 0 ;
15761550 struct string_list packfile_uris = STRING_LIST_INIT_DUP ;
15771551 int i ;
15781552 struct strvec index_pack_args = STRVEC_INIT ;
@@ -1631,22 +1605,22 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
16311605 break ;
16321606 case FETCH_PROCESS_ACKS :
16331607 /* 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 ) {
16361616 /*
16371617 * Don't check for response delimiter; get_pack() will
16381618 * read the rest of this response.
16391619 */
16401620 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 {
16471622 do_check_stateless_delimiter (args , & reader );
16481623 state = FETCH_SEND_REQUEST ;
1649- break ;
16501624 }
16511625 break ;
16521626 case FETCH_GET_PACK :
0 commit comments