Skip to content

Commit a217dcb

Browse files
mhaggergitster
authored andcommitted
handle_one_ref(): rewrite to take an object_id argument
Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e23b036 commit a217dcb

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

revision.c

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,17 +1218,18 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
12181218
return 0;
12191219
}
12201220

1221-
static int handle_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
1221+
static int handle_one_ref(const char *path, const struct object_id *oid,
1222+
int flag, void *cb_data)
12221223
{
12231224
struct all_refs_cb *cb = cb_data;
12241225
struct object *object;
12251226

12261227
if (ref_excluded(cb->all_revs->ref_excludes, path))
12271228
return 0;
12281229

1229-
object = get_reference(cb->all_revs, path, sha1, cb->all_flags);
1230+
object = get_reference(cb->all_revs, path, oid->hash, cb->all_flags);
12301231
add_rev_cmdline(cb->all_revs, object, path, REV_CMD_REF, cb->all_flags);
1231-
add_pending_sha1(cb->all_revs, path, sha1, cb->all_flags);
1232+
add_pending_sha1(cb->all_revs, path, oid->hash, cb->all_flags);
12321233
return 0;
12331234
}
12341235

@@ -1261,11 +1262,8 @@ static void handle_refs(const char *submodule, struct rev_info *revs, unsigned f
12611262
int (*for_each)(const char *, each_ref_fn, void *))
12621263
{
12631264
struct all_refs_cb cb;
1264-
struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
1265-
{handle_one_ref, &cb};
1266-
12671265
init_all_refs_cb(&cb, revs, flags);
1268-
for_each(submodule, each_ref_fn_adapter, &wrapped_handle_one_ref);
1266+
for_each(submodule, handle_one_ref, &cb);
12691267
}
12701268

12711269
static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
@@ -2126,42 +2124,27 @@ static int handle_revision_pseudo_opt(const char *submodule,
21262124
clear_ref_exclusion(&revs->ref_excludes);
21272125
} else if ((argcount = parse_long_opt("glob", argv, &optarg))) {
21282126
struct all_refs_cb cb;
2129-
struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
2130-
{handle_one_ref, &cb};
2131-
21322127
init_all_refs_cb(&cb, revs, *flags);
2133-
for_each_glob_ref(each_ref_fn_adapter, optarg, &wrapped_handle_one_ref);
2128+
for_each_glob_ref(handle_one_ref, optarg, &cb);
21342129
clear_ref_exclusion(&revs->ref_excludes);
21352130
return argcount;
21362131
} else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {
21372132
add_ref_exclusion(&revs->ref_excludes, optarg);
21382133
return argcount;
21392134
} else if (starts_with(arg, "--branches=")) {
21402135
struct all_refs_cb cb;
2141-
struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
2142-
{handle_one_ref, &cb};
2143-
21442136
init_all_refs_cb(&cb, revs, *flags);
2145-
for_each_glob_ref_in(each_ref_fn_adapter, arg + 11, "refs/heads/",
2146-
&wrapped_handle_one_ref);
2137+
for_each_glob_ref_in(handle_one_ref, arg + 11, "refs/heads/", &cb);
21472138
clear_ref_exclusion(&revs->ref_excludes);
21482139
} else if (starts_with(arg, "--tags=")) {
21492140
struct all_refs_cb cb;
2150-
struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
2151-
{handle_one_ref, &cb};
2152-
21532141
init_all_refs_cb(&cb, revs, *flags);
2154-
for_each_glob_ref_in(each_ref_fn_adapter, arg + 7, "refs/tags/",
2155-
&wrapped_handle_one_ref);
2142+
for_each_glob_ref_in(handle_one_ref, arg + 7, "refs/tags/", &cb);
21562143
clear_ref_exclusion(&revs->ref_excludes);
21572144
} else if (starts_with(arg, "--remotes=")) {
21582145
struct all_refs_cb cb;
2159-
struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
2160-
{handle_one_ref, &cb};
2161-
21622146
init_all_refs_cb(&cb, revs, *flags);
2163-
for_each_glob_ref_in(each_ref_fn_adapter, arg + 10, "refs/remotes/",
2164-
&wrapped_handle_one_ref);
2147+
for_each_glob_ref_in(handle_one_ref, arg + 10, "refs/remotes/", &cb);
21652148
clear_ref_exclusion(&revs->ref_excludes);
21662149
} else if (!strcmp(arg, "--reflog")) {
21672150
add_reflogs_to_pending(revs, *flags);

0 commit comments

Comments
 (0)