sha1-name.c: remove the_repo from handle_one_ref()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Apr 16, 2019 at 16:33 UTC
c931ba4e7806d4e76d367153cb8eaae022b83be7
1 file changed
+14
-5
sha1-name.c
+14
-5
@@ -1189,15 +1189,21 @@ static enum get_oid_result get_oid_1(struct repository *r,
1189
/* Remember to update object flag allocation in object.h */
1190
#define ONELINE_SEEN (1u<<20)
1191
1192
+struct handle_one_ref_cb {
1193
+ struct repository *repo;
1194
+ struct commit_list **list;
1195
+};
1196
+
1197
static int handle_one_ref(const char *path, const struct object_id *oid,
1198
int flag, void *cb_data)
1199
{
1195
- struct commit_list **list = cb_data;
1196
- struct object *object = parse_object(the_repository, oid);
1200
+ struct handle_one_ref_cb *cb = cb_data;
1201
+ struct commit_list **list = cb->list;
1202
+ struct object *object = parse_object(cb->repo, oid);
1203
if (!object)
1204
return 0;
1205
if (object->type == OBJ_TAG) {
1200
- object = deref_tag(the_repository, object, path,
1206
+ object = deref_tag(cb->repo, object, path,
1207
strlen(path));
1208
if (!object)
1209
return 0;
@@ -1760,10 +1766,13 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
1766
char *new_path = NULL;
1767
int pos;
1768
if (!only_to_die && namelen > 2 && name[1] == '/') {
1769
+ struct handle_one_ref_cb cb;
1770
struct commit_list *list = NULL;
1771
1765
- for_each_ref(handle_one_ref, &list);
1766
- head_ref(handle_one_ref, &list);
1772
+ cb.repo = repo;
1773
+ cb.list = &list;
1774
+ refs_for_each_ref(repo->refs, handle_one_ref, &cb);
1775
+ refs_head_ref(repo->refs, handle_one_ref, &cb);
1776
commit_list_sort_by_date(&list);
1777
return get_oid_oneline(repo, name + 2, oid, list);
1778
}