* This function marks a rev and its ancestors as common. * In some cases, it is desirable to mark only the ancestors (for example * when only the server does not yet know that they are common). */
| 55 | * when only the server does not yet know that they are common). |
| 56 | */ |
| 57 | static void mark_common(struct negotiation_state *ns, struct commit *commit, |
| 58 | int ancestors_only, int dont_parse) |
| 59 | { |
| 60 | struct commit_stack stack = COMMIT_STACK_INIT; |
| 61 | |
| 62 | if (!commit || (commit->object.flags & COMMON)) |
| 63 | return; |
| 64 | |
| 65 | commit_stack_push(&stack, commit); |
| 66 | if (!ancestors_only) { |
| 67 | commit->object.flags |= COMMON; |
| 68 | |
| 69 | if ((commit->object.flags & SEEN) && !(commit->object.flags & POPPED)) |
| 70 | ns->non_common_revs--; |
| 71 | } |
| 72 | while ((commit = commit_stack_pop(&stack))) { |
| 73 | struct object *o = (struct object *)commit; |
| 74 | |
| 75 | if (!(o->flags & SEEN)) |
| 76 | rev_list_push(ns, commit, SEEN); |
| 77 | else { |
| 78 | struct commit_list *parents; |
| 79 | |
| 80 | if (!o->parsed && !dont_parse) |
| 81 | if (repo_parse_commit(the_repository, commit)) |
| 82 | continue; |
| 83 | |
| 84 | for (parents = commit->parents; |
| 85 | parents; |
| 86 | parents = parents->next) { |
| 87 | struct commit *p = parents->item; |
| 88 | |
| 89 | if (p->object.flags & COMMON) |
| 90 | continue; |
| 91 | |
| 92 | p->object.flags |= COMMON; |
| 93 | |
| 94 | if ((p->object.flags & SEEN) && !(p->object.flags & POPPED)) |
| 95 | ns->non_common_revs--; |
| 96 | |
| 97 | commit_stack_push(&stack, parents->item); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | commit_stack_clear(&stack); |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | * Get the next rev to send, ignoring the common. |
no test coverage detected