diff --git a/sha1-name.c b/sha1-name.c index 5741a9f821..d9050776dd 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1189,15 +1189,21 @@ static enum get_oid_result get_oid_1(struct repository *r, /* Remember to update object flag allocation in object.h */ #define ONELINE_SEEN (1u<<20) +struct handle_one_ref_cb { + struct repository *repo; + struct commit_list **list; +}; + static int handle_one_ref(const char *path, const struct object_id *oid, int flag, void *cb_data) { - struct commit_list **list = cb_data; - struct object *object = parse_object(the_repository, oid); + struct handle_one_ref_cb *cb = cb_data; + struct commit_list **list = cb->list; + struct object *object = parse_object(cb->repo, oid); if (!object) return 0; if (object->type == OBJ_TAG) { - object = deref_tag(the_repository, object, path, + object = deref_tag(cb->repo, object, path, strlen(path)); if (!object) return 0; @@ -1760,10 +1766,13 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, char *new_path = NULL; int pos; if (!only_to_die && namelen > 2 && name[1] == '/') { + struct handle_one_ref_cb cb; struct commit_list *list = NULL; - for_each_ref(handle_one_ref, &list); - head_ref(handle_one_ref, &list); + cb.repo = repo; + cb.list = &list; + refs_for_each_ref(repo->refs, handle_one_ref, &cb); + refs_head_ref(repo->refs, handle_one_ref, &cb); commit_list_sort_by_date(&list); return get_oid_oneline(repo, name + 2, oid, list); }