Skip to content

Commit d093bc7

Browse files
jonathantanmygitster
authored andcommitted
fetch-pack: move common check and marking together
When receiving 'ACK <object-id> continue' for a common commit, check if the commit was already known to be common and mark it as such if not up front. This should make future refactoring of how the information about common commits is stored more straightforward. No visible change intended. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d30fe89 commit d093bc7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fetch-pack.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,14 @@ static int find_common(struct negotiation_state *ns,
505505
case ACK_continue: {
506506
struct commit *commit =
507507
lookup_commit(result_oid);
508+
int was_common;
508509
if (!commit)
509510
die(_("invalid commit %s"), oid_to_hex(result_oid));
511+
was_common = commit->object.flags & COMMON;
512+
mark_common(ns, commit, 0, 1);
510513
if (args->stateless_rpc
511514
&& ack == ACK_common
512-
&& !(commit->object.flags & COMMON)) {
515+
&& !was_common) {
513516
/* We need to replay the have for this object
514517
* on the next RPC request so the peer knows
515518
* it is in common with us.
@@ -526,7 +529,6 @@ static int find_common(struct negotiation_state *ns,
526529
} else if (!args->stateless_rpc
527530
|| ack != ACK_common)
528531
in_vain = 0;
529-
mark_common(ns, commit, 0, 1);
530532
retval = 0;
531533
got_continue = 1;
532534
if (ack == ACK_ready)

0 commit comments

Comments
 (0)