| 3983 | } |
| 3984 | |
| 3985 | static struct commit *lookup_label(struct repository *r, const char *label, |
| 3986 | int len, struct strbuf *buf) |
| 3987 | { |
| 3988 | struct commit *commit; |
| 3989 | struct object_id oid; |
| 3990 | |
| 3991 | strbuf_reset(buf); |
| 3992 | strbuf_addf(buf, "refs/rewritten/%.*s", len, label); |
| 3993 | if (!refs_read_ref(get_main_ref_store(the_repository), buf->buf, &oid)) { |
| 3994 | commit = lookup_commit_object(r, &oid); |
| 3995 | } else { |
| 3996 | /* fall back to non-rewritten ref or commit */ |
| 3997 | strbuf_splice(buf, 0, strlen("refs/rewritten/"), "", 0); |
| 3998 | commit = lookup_commit_reference_by_name(buf->buf); |
| 3999 | } |
| 4000 | |
| 4001 | if (!commit) |
| 4002 | error(_("could not resolve '%s'"), buf->buf); |
| 4003 | |
| 4004 | return commit; |
| 4005 | } |
| 4006 | |
| 4007 | static int do_reset(struct repository *r, |
| 4008 | const char *name, int len, |
no test coverage detected