| 826 | } |
| 827 | |
| 828 | static 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 | |
| 858 | static enum get_oid_result get_nth_ancestor(struct repository *r, |
| 859 | const char *name, int len, |
no test coverage detected