handle_one_ref(): rewrite to take an object_id argument
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
May 25, 2015 at 18:38 UTC
a217dcbd1efb8d68baf3dc9765aa8789970527fd
1 file changed
+9
-26
revision.c
+9
-26
@@ -1218,7 +1218,8 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
1218
return 0;
1219
}
1220
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)
1223
{
1224
struct all_refs_cb *cb = cb_data;
1225
struct object *object;
@@ -1226,9 +1227,9 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag,
1227
if (ref_excluded(cb->all_revs->ref_excludes, path))
1228
return 0;
1229
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);
1231
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);
1233
return 0;
1234
}
1235
@@ -1261,11 +1262,8 @@ static void handle_refs(const char *submodule, struct rev_info *revs, unsigned f
1262
int (*for_each)(const char *, each_ref_fn, void *))
1263
{
1264
struct all_refs_cb cb;
1264
- struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
1265
- {handle_one_ref, &cb};
1266
-
1265
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);
1267
}
1268
1269
static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
@@ -2126,11 +2124,8 @@ static int handle_revision_pseudo_opt(const char *submodule,
2124
clear_ref_exclusion(&revs->ref_excludes);
2125
} else if ((argcount = parse_long_opt("glob", argv, &optarg))) {
2126
struct all_refs_cb cb;
2129
- struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
2130
- {handle_one_ref, &cb};
2131
-
2127
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);
2129
clear_ref_exclusion(&revs->ref_excludes);
2130
return argcount;
2131
} else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {
@@ -2138,30 +2133,18 @@ static int handle_revision_pseudo_opt(const char *submodule,
2133
return argcount;
2134
} else if (starts_with(arg, "--branches=")) {
2135
struct all_refs_cb cb;
2141
- struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
2142
- {handle_one_ref, &cb};
2143
-
2136
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);
2138
clear_ref_exclusion(&revs->ref_excludes);
2139
} else if (starts_with(arg, "--tags=")) {
2140
struct all_refs_cb cb;
2150
- struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
2151
- {handle_one_ref, &cb};
2152
-
2141
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);
2143
clear_ref_exclusion(&revs->ref_excludes);
2144
} else if (starts_with(arg, "--remotes=")) {
2145
struct all_refs_cb cb;
2159
- struct each_ref_fn_sha1_adapter wrapped_handle_one_ref =
2160
- {handle_one_ref, &cb};
2161
-
2146
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);
2148
clear_ref_exclusion(&revs->ref_excludes);
2149
} else if (!strcmp(arg, "--reflog")) {
2150
add_reflogs_to_pending(revs, *flags);