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

Function merge_bases_many

commit-reach.c:193–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193static int merge_bases_many(struct repository *r,
194 struct commit *one, int n,
195 struct commit **twos,
196 enum merge_base_flags mb_flags,
197 struct commit_list **result)
198{
199 struct commit_list *list = NULL, **tail = result;
200 int i;
201
202 for (i = 0; i < n; i++) {
203 if (one == twos[i]) {
204 /*
205 * We do not mark this even with RESULT so we do not
206 * have to clean it up.
207 */
208 *result = commit_list_insert(one, result);
209 return 0;
210 }
211 }
212
213 if (!one)
214 return 0;
215 if (repo_parse_commit(r, one))
216 return error(_("could not parse commit %s"),
217 oid_to_hex(&one->object.oid));
218 for (i = 0; i < n; i++) {
219 if (!twos[i])
220 return 0;
221 if (repo_parse_commit(r, twos[i]))
222 return error(_("could not parse commit %s"),
223 oid_to_hex(&twos[i]->object.oid));
224 }
225
226 if (paint_down_to_common(r, one, n, twos, 0, mb_flags, &list)) {
227 commit_list_free(list);
228 return -1;
229 }
230
231 while (list) {
232 struct commit *commit = pop_commit(&list);
233 if (!(commit->object.flags & STALE))
234 tail = commit_list_append(commit, tail);
235 }
236 commit_list_sort_by_date(result);
237 return 0;
238}
239
240int get_octopus_merge_bases(struct commit_list *in, struct commit_list **result)
241{

Callers 1

get_merge_bases_many_0Function · 0.85

Calls 9

commit_list_insertFunction · 0.85
repo_parse_commitFunction · 0.85
errorFunction · 0.85
oid_to_hexFunction · 0.85
paint_down_to_commonFunction · 0.85
commit_list_freeFunction · 0.85
pop_commitFunction · 0.85
commit_list_appendFunction · 0.85
commit_list_sort_by_dateFunction · 0.85

Tested by

no test coverage detected