MCPcopy Index your code
hub / github.com/git/git / tips_reachable_from_bases

Function tips_reachable_from_bases

commit-reach.c:1212–1306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1210}
1211
1212void tips_reachable_from_bases(struct repository *r,
1213 struct commit_list *bases,
1214 struct commit **tips, size_t tips_nr,
1215 int mark)
1216{
1217 struct commit_and_index *commits;
1218 size_t min_generation_index = 0;
1219 timestamp_t min_generation;
1220 struct commit_list *stack = NULL;
1221
1222 if (!bases || !tips || !tips_nr)
1223 return;
1224
1225 /*
1226 * Do a depth-first search starting at 'bases' to search for the
1227 * tips. Stop at the lowest (un-found) generation number. When
1228 * finding the lowest commit, increase the minimum generation
1229 * number to the next lowest (un-found) generation number.
1230 */
1231
1232 CALLOC_ARRAY(commits, tips_nr);
1233
1234 for (size_t i = 0; i < tips_nr; i++) {
1235 commits[i].commit = tips[i];
1236 commits[i].generation = commit_graph_generation(tips[i]);
1237 }
1238
1239 /* Sort with generation number ascending. */
1240 QSORT(commits, tips_nr, compare_commit_and_index_by_generation);
1241 min_generation = commits[0].generation;
1242
1243 for (size_t i = 0; i < tips_nr; i++)
1244 commits[i].commit->object.flags |= RESULT;
1245
1246 while (bases) {
1247 repo_parse_commit(r, bases->item);
1248 commit_list_insert(bases->item, &stack);
1249 bases = bases->next;
1250 }
1251
1252 while (stack) {
1253 int explored_all_parents = 1;
1254 struct commit_list *p;
1255 struct commit *c = stack->item;
1256
1257 /* Does it match any of our tips? */
1258 {
1259 if (c->object.flags & RESULT) {
1260 c->object.flags |= mark;
1261
1262 if (commits[min_generation_index].commit->object.flags & mark) {
1263 unsigned int k = min_generation_index + 1;
1264 while (k < tips_nr &&
1265 (commits[k].commit->object.flags & mark))
1266 k++;
1267
1268 /* Terminate early if all found. */
1269 if (k >= tips_nr)

Callers 1

reach_filterFunction · 0.85

Calls 6

commit_graph_generationFunction · 0.85
repo_parse_commitFunction · 0.85
commit_list_insertFunction · 0.85
pop_commitFunction · 0.85
repo_clear_commit_marksFunction · 0.85
commit_list_freeFunction · 0.85

Tested by

no test coverage detected