fetch-pack: move common check and marking together
[gitweb.git] / fetch-pack.c
index 86252e1cf7d299eb7a4467bfdb8bf663b985d9db..d07646575f78f972a5f40b5eead3a21ef604660d 100644 (file)
@@ -505,11 +505,14 @@ static int find_common(struct negotiation_state *ns,
                                case ACK_continue: {
                                        struct commit *commit =
                                                lookup_commit(result_oid);
+                                       int was_common;
                                        if (!commit)
                                                die(_("invalid commit %s"), oid_to_hex(result_oid));
+                                       was_common = commit->object.flags & COMMON;
+                                       mark_common(ns, commit, 0, 1);
                                        if (args->stateless_rpc
                                         && ack == ACK_common
-                                        && !(commit->object.flags & COMMON)) {
+                                        && !was_common) {
                                                /* We need to replay the have for this object
                                                 * on the next RPC request so the peer knows
                                                 * it is in common with us.
@@ -526,7 +529,6 @@ static int find_common(struct negotiation_state *ns,
                                        } else if (!args->stateless_rpc
                                                   || ack != ACK_common)
                                                in_vain = 0;
-                                       mark_common(ns, commit, 0, 1);
                                        retval = 0;
                                        got_continue = 1;
                                        if (ack == ACK_ready)