| 40 | const char *commit_type = "commit"; |
| 41 | |
| 42 | struct commit *lookup_commit_reference_gently(struct repository *r, |
| 43 | const struct object_id *oid, int quiet) |
| 44 | { |
| 45 | const struct object_id *maybe_peeled; |
| 46 | struct object_id peeled_oid; |
| 47 | struct commit *commit; |
| 48 | enum object_type type; |
| 49 | |
| 50 | switch (peel_object_ext(r, oid, &peeled_oid, 0, &type)) { |
| 51 | case PEEL_NON_TAG: |
| 52 | maybe_peeled = oid; |
| 53 | break; |
| 54 | case PEEL_PEELED: |
| 55 | maybe_peeled = &peeled_oid; |
| 56 | break; |
| 57 | default: |
| 58 | return NULL; |
| 59 | } |
| 60 | |
| 61 | if (type != OBJ_COMMIT) { |
| 62 | if (!quiet) |
| 63 | error(_("object %s is a %s, not a %s"), |
| 64 | oid_to_hex(oid), type_name(type), |
| 65 | type_name(OBJ_COMMIT)); |
| 66 | return NULL; |
| 67 | } |
| 68 | |
| 69 | commit = lookup_commit(r, maybe_peeled); |
| 70 | if (!commit || repo_parse_commit_gently(r, commit, quiet) < 0) |
| 71 | return NULL; |
| 72 | |
| 73 | return commit; |
| 74 | } |
| 75 | |
| 76 | struct commit *lookup_commit_reference(struct repository *r, const struct object_id *oid) |
| 77 | { |
no test coverage detected