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 <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Jun 14, 2018 at 15:54 UTC d093bc7582fc60b51b42d2edf32b3ce68cd283eb
1 file changed +4 -2
fetch-pack.c
+4 -2
@@ -505,11 +505,14 @@ static int find_common(struct negotiation_state *ns,
505 case ACK_continue: {
506 struct commit *commit =
507 lookup_commit(result_oid);
508 + int was_common;
509 if (!commit)
510 die(_("invalid commit %s"), oid_to_hex(result_oid));
511 + was_common = commit->object.flags & COMMON;
512 + mark_common(ns, commit, 0, 1);
513 if (args->stateless_rpc
514 && ack == ACK_common
512 - && !(commit->object.flags & COMMON)) {
515 + && !was_common) {
516 /* We need to replay the have for this object
517 * on the next RPC request so the peer knows
518 * it is in common with us.
@@ -526,7 +529,6 @@ static int find_common(struct negotiation_state *ns,
529 } else if (!args->stateless_rpc
530 || ack != ACK_common)
531 in_vain = 0;
529 - mark_common(ns, commit, 0, 1);
532 retval = 0;
533 got_continue = 1;
534 if (ack == ACK_ready)