Skip to content

Commit 21bcf6e

Browse files
jonathantanmygitster
authored andcommitted
fetch-pack: directly end negotiation if ACK ready
When "ACK %s ready" is received, find_common() clears rev_list in an attempt to stop further "have" lines from being sent [1]. It is much more readable to explicitly break from the loop instead. So explicitly break from the loop, and make the clearing of the rev_list happen unconditionally. [1] The rationale is further described in the originating commit f2cba92 ("fetch-pack: Finish negotation if remote replies "ACK %s ready"", 2011-03-14). Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af00855 commit 21bcf6e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fetch-pack.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,8 @@ static int find_common(struct fetch_pack_args *args,
517517
mark_common(commit, 0, 1);
518518
retval = 0;
519519
got_continue = 1;
520-
if (ack == ACK_ready) {
521-
clear_prio_queue(&rev_list);
520+
if (ack == ACK_ready)
522521
got_ready = 1;
523-
}
524522
break;
525523
}
526524
}
@@ -530,6 +528,8 @@ static int find_common(struct fetch_pack_args *args,
530528
print_verbose(args, _("giving up"));
531529
break; /* give up */
532530
}
531+
if (got_ready)
532+
break;
533533
}
534534
}
535535
done:
@@ -1096,6 +1096,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
10961096
die(_("git fetch-pack: fetch failed."));
10971097

10981098
all_done:
1099+
clear_prio_queue(&rev_list);
10991100
return ref;
11001101
}
11011102

@@ -1300,7 +1301,6 @@ static int process_acks(struct packet_reader *reader, struct oidset *common)
13001301
}
13011302

13021303
if (!strcmp(reader->line, "ready")) {
1303-
clear_prio_queue(&rev_list);
13041304
received_ready = 1;
13051305
continue;
13061306
}
@@ -1441,6 +1441,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
14411441
}
14421442
}
14431443

1444+
clear_prio_queue(&rev_list);
14441445
oidset_clear(&common);
14451446
return ref;
14461447
}

0 commit comments

Comments
 (0)