Skip to content

Commit

Permalink
sha1-name.c: remove the_repo from handle_one_ref()
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
pclouds authored and gitster committed Apr 16, 2019
1 parent 2b1790f commit c931ba4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions sha1-name.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit c931ba4

Please sign in to comment.