@@ -27,6 +27,7 @@ static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<
2727static unsigned long oldest_have ;
2828
2929static int multi_ack , nr_our_refs ;
30+ static int no_done ;
3031static int use_thin_pack , use_ofs_delta , use_include_tag ;
3132static int no_progress , daemon_mode ;
3233static int shallow_nr ;
@@ -429,6 +430,9 @@ static int get_common_commits(void)
429430 static char line [1000 ];
430431 unsigned char sha1 [20 ];
431432 char last_hex [41 ];
433+ int got_common = 0 ;
434+ int got_other = 0 ;
435+ int sent_ready = 0 ;
432436
433437 save_commit_buffer = 0 ;
434438
@@ -437,25 +441,40 @@ static int get_common_commits(void)
437441 reset_timeout ();
438442
439443 if (!len ) {
444+ if (multi_ack == 2 && got_common
445+ && !got_other && ok_to_give_up ()) {
446+ sent_ready = 1 ;
447+ packet_write (1 , "ACK %s ready\n" , last_hex );
448+ }
440449 if (have_obj .nr == 0 || multi_ack )
441450 packet_write (1 , "NAK\n" );
451+
452+ if (no_done && sent_ready ) {
453+ packet_write (1 , "ACK %s\n" , last_hex );
454+ return 0 ;
455+ }
442456 if (stateless_rpc )
443457 exit (0 );
458+ got_common = 0 ;
459+ got_other = 0 ;
444460 continue ;
445461 }
446462 strip (line , len );
447463 if (!prefixcmp (line , "have " )) {
448464 switch (got_sha1 (line + 5 , sha1 )) {
449465 case -1 : /* they have what we do not */
466+ got_other = 1 ;
450467 if (multi_ack && ok_to_give_up ()) {
451468 const char * hex = sha1_to_hex (sha1 );
452- if (multi_ack == 2 )
469+ if (multi_ack == 2 ) {
470+ sent_ready = 1 ;
453471 packet_write (1 , "ACK %s ready\n" , hex );
454- else
472+ } else
455473 packet_write (1 , "ACK %s continue\n" , hex );
456474 }
457475 break ;
458476 default :
477+ got_common = 1 ;
459478 memcpy (last_hex , sha1_to_hex (sha1 ), 41 );
460479 if (multi_ack == 2 )
461480 packet_write (1 , "ACK %s common\n" , last_hex );
@@ -526,6 +545,8 @@ static void receive_needs(void)
526545 multi_ack = 2 ;
527546 else if (strstr (line + 45 , "multi_ack" ))
528547 multi_ack = 1 ;
548+ if (strstr (line + 45 , "no-done" ))
549+ no_done = 1 ;
529550 if (strstr (line + 45 , "thin-pack" ))
530551 use_thin_pack = 1 ;
531552 if (strstr (line + 45 , "ofs-delta" ))
@@ -619,7 +640,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
619640{
620641 static const char * capabilities = "multi_ack thin-pack side-band"
621642 " side-band-64k ofs-delta shallow no-progress"
622- " include-tag multi_ack_detailed" ;
643+ " include-tag multi_ack_detailed no-done " ;
623644 struct object * o = parse_object (sha1 );
624645
625646 if (!o )
0 commit comments