MCPcopy Create free account
hub / github.com/git/git / get_rev

Function get_rev

negotiator/default.c:108–148  ·  view source on GitHub ↗

* Get the next rev to send, ignoring the common. */

Source from the content-addressed store, hash-verified

106 * Get the next rev to send, ignoring the common.
107 */
108static const struct object_id *get_rev(struct negotiation_state *ns)
109{
110 struct commit *commit = NULL;
111
112 while (commit == NULL) {
113 unsigned int mark;
114 struct commit_list *parents;
115
116 if (ns->rev_list.nr == 0 || ns->non_common_revs == 0)
117 return NULL;
118
119 commit = prio_queue_get(&ns->rev_list);
120 repo_parse_commit(the_repository, commit);
121 parents = commit->parents;
122
123 commit->object.flags |= POPPED;
124 if (!(commit->object.flags & COMMON))
125 ns->non_common_revs--;
126
127 if (commit->object.flags & COMMON) {
128 /* do not send "have", and ignore ancestors */
129 commit = NULL;
130 mark = COMMON | SEEN;
131 } else if (commit->object.flags & COMMON_REF)
132 /* send "have", and ignore ancestors */
133 mark = COMMON | SEEN;
134 else
135 /* send "have", also for its ancestors */
136 mark = SEEN;
137
138 while (parents) {
139 if (!(parents->item->object.flags & SEEN))
140 rev_list_push(ns, parents->item, mark);
141 if (mark & COMMON)
142 mark_common(ns, parents->item, 1, 0);
143 parents = parents->next;
144 }
145 }
146
147 return &commit->object.oid;
148}
149
150static void known_common(struct fetch_negotiator *n, struct commit *c)
151{

Callers 1

nextFunction · 0.70

Calls 4

prio_queue_getFunction · 0.85
repo_parse_commitFunction · 0.85
rev_list_pushFunction · 0.70
mark_commonFunction · 0.70

Tested by

no test coverage detected