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

Function remove_redundant_no_gen

commit-reach.c:274–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274static int remove_redundant_no_gen(struct repository *r,
275 struct commit **array,
276 size_t cnt, size_t *dedup_cnt)
277{
278 struct commit **work;
279 unsigned char *redundant;
280 size_t *filled_index;
281 size_t i, j, filled;
282
283 CALLOC_ARRAY(work, cnt);
284 redundant = xcalloc(cnt, 1);
285 ALLOC_ARRAY(filled_index, cnt - 1);
286
287 for (i = 0; i < cnt; i++)
288 repo_parse_commit(r, array[i]);
289 for (i = 0; i < cnt; i++) {
290 struct commit_list *common = NULL;
291 timestamp_t min_generation = commit_graph_generation(array[i]);
292
293 if (redundant[i])
294 continue;
295 for (j = filled = 0; j < cnt; j++) {
296 timestamp_t curr_generation;
297 if (i == j || redundant[j])
298 continue;
299 filled_index[filled] = j;
300 work[filled++] = array[j];
301
302 curr_generation = commit_graph_generation(array[j]);
303 if (curr_generation < min_generation)
304 min_generation = curr_generation;
305 }
306 if (paint_down_to_common(r, array[i], filled,
307 work, min_generation,
308 MERGE_BASE_FIND_ALL, &common)) {
309 clear_commit_marks(array[i], all_flags);
310 clear_commit_marks_many(filled, work, all_flags);
311 commit_list_free(common);
312 free(work);
313 free(redundant);
314 free(filled_index);
315 return -1;
316 }
317 if (array[i]->object.flags & PARENT2)
318 redundant[i] = 1;
319 for (j = 0; j < filled; j++)
320 if (work[j]->object.flags & PARENT1)
321 redundant[filled_index[j]] = 1;
322 clear_commit_marks(array[i], all_flags);
323 clear_commit_marks_many(filled, work, all_flags);
324 commit_list_free(common);
325 }
326
327 /* Now collect the result */
328 COPY_ARRAY(work, array, cnt);
329 for (i = filled = 0; i < cnt; i++)
330 if (!redundant[i])
331 array[filled++] = work[i];

Callers 1

remove_redundantFunction · 0.85

Calls 7

xcallocFunction · 0.85
repo_parse_commitFunction · 0.85
commit_graph_generationFunction · 0.85
paint_down_to_commonFunction · 0.85
clear_commit_marksFunction · 0.85
clear_commit_marks_manyFunction · 0.85
commit_list_freeFunction · 0.85

Tested by

no test coverage detected