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

Function get_parent

object-name.c:828–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

826}
827
828static enum get_oid_result get_parent(struct repository *r,
829 const char *name, int len,
830 struct object_id *result, int idx)
831{
832 struct object_id oid;
833 enum get_oid_result ret = get_oid_1(r, name, len, &oid,
834 GET_OID_COMMITTISH);
835 struct commit *commit;
836 struct commit_list *p;
837
838 if (ret)
839 return ret;
840 commit = lookup_commit_reference(r, &oid);
841 if (repo_parse_commit(r, commit))
842 return MISSING_OBJECT;
843 if (!idx) {
844 oidcpy(result, &commit->object.oid);
845 return FOUND;
846 }
847 p = commit->parents;
848 while (p) {
849 if (!--idx) {
850 oidcpy(result, &p->item->object.oid);
851 return FOUND;
852 }
853 p = p->next;
854 }
855 return MISSING_OBJECT;
856}
857
858static enum get_oid_result get_nth_ancestor(struct repository *r,
859 const char *name, int len,

Callers 1

get_oid_1Function · 0.85

Calls 4

get_oid_1Function · 0.85
lookup_commit_referenceFunction · 0.85
repo_parse_commitFunction · 0.85
oidcpyFunction · 0.85

Tested by

no test coverage detected