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

Function best_bisection_sorted

bisect.c:227–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227static struct commit_list *best_bisection_sorted(struct commit_list *list, int nr)
228{
229 struct commit_list *p;
230 struct commit_dist *array = xcalloc(nr, sizeof(*array));
231 struct strbuf buf = STRBUF_INIT;
232 int cnt, i;
233
234 for (p = list, cnt = 0; p; p = p->next) {
235 int distance;
236 unsigned commit_flags = p->item->object.flags;
237
238 if (commit_flags & TREESAME)
239 continue;
240 distance = weight(p);
241 if (nr - distance < distance)
242 distance = nr - distance;
243 array[cnt].commit = p->item;
244 array[cnt].distance = distance;
245 cnt++;
246 }
247 QSORT(array, cnt, compare_commit_dist);
248 for (p = list, i = 0; i < cnt; i++) {
249 struct object *obj = &(array[i].commit->object);
250
251 strbuf_reset(&buf);
252 strbuf_addf(&buf, "dist=%d", array[i].distance);
253 add_name_decoration(DECORATION_NONE, buf.buf, obj);
254
255 p->item = array[i].commit;
256 if (i < cnt - 1)
257 p = p->next;
258 }
259 if (p) {
260 commit_list_free(p->next);
261 p->next = NULL;
262 }
263 strbuf_release(&buf);
264 free(array);
265 return list;
266}
267
268/*
269 * zero or positive weight is the number of interesting commits it can

Callers 1

do_find_bisectionFunction · 0.85

Calls 6

xcallocFunction · 0.85
weightFunction · 0.85
strbuf_addfFunction · 0.85
add_name_decorationFunction · 0.85
commit_list_freeFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected