refs.c: upgrade for_each_replace_ref to be a each_repo_ref_fn callback

Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Aug 20, 2018 at 18:24 UTC 212e0f7efe163d062dcd393a0788cf3f93544a6e
4 files changed +12 -12
builtin/replace.c
+4 -4
@@ -39,7 +39,8 @@ struct show_data {
39 enum replace_format format;
40 };
41
42 -static int show_reference(const char *refname, const struct object_id *oid,
42 +static int show_reference(struct repository *r, const char *refname,
43 + const struct object_id *oid,
44 int flag, void *cb_data)
45 {
46 struct show_data *data = cb_data;
@@ -56,9 +57,8 @@ static int show_reference(const char *refname, const struct object_id *oid,
57 if (get_oid(refname, &object))
58 return error("Failed to resolve '%s' as a valid ref.", refname);
59
59 - obj_type = oid_object_info(the_repository, &object,
60 - NULL);
61 - repl_type = oid_object_info(the_repository, oid, NULL);
60 + obj_type = oid_object_info(r, &object, NULL);
61 + repl_type = oid_object_info(r, oid, NULL);
62
63 printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
64 oid_to_hex(oid), type_name(repl_type));
refs.c
+4 -5
@@ -1474,12 +1474,11 @@ int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
1474 return do_for_each_ref(refs, prefix, fn, 0, flag, cb_data);
1475 }
1476
1477 -int for_each_replace_ref(struct repository *r, each_ref_fn fn, void *cb_data)
1477 +int for_each_replace_ref(struct repository *r, each_repo_ref_fn fn, void *cb_data)
1478 {
1479 - return do_for_each_ref(get_main_ref_store(r),
1480 - git_replace_ref_base, fn,
1481 - strlen(git_replace_ref_base),
1482 - DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
1479 + return do_for_each_repo_ref(r, git_replace_ref_base, fn,
1480 + strlen(git_replace_ref_base),
1481 + DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
1482 }
1483
1484 int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)
refs.h
+1 -1
@@ -317,7 +317,7 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data,
317 int for_each_tag_ref(each_ref_fn fn, void *cb_data);
318 int for_each_branch_ref(each_ref_fn fn, void *cb_data);
319 int for_each_remote_ref(each_ref_fn fn, void *cb_data);
320 -int for_each_replace_ref(struct repository *r, each_ref_fn fn, void *cb_data);
320 +int for_each_replace_ref(struct repository *r, each_repo_ref_fn fn, void *cb_data);
321 int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data);
322 int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
323 const char *prefix, void *cb_data);
replace-object.c
+3 -2
@@ -6,7 +6,8 @@
6 #include "repository.h"
7 #include "commit.h"
8
9 -static int register_replace_ref(const char *refname,
9 +static int register_replace_ref(struct repository *r,
10 + const char *refname,
11 const struct object_id *oid,
12 int flag, void *cb_data)
13 {
@@ -25,7 +26,7 @@ static int register_replace_ref(const char *refname,
26 oidcpy(&repl_obj->replacement, oid);
27
28 /* Register new object */
28 - if (oidmap_put(the_repository->objects->replace_map, repl_obj))
29 + if (oidmap_put(r->objects->replace_map, repl_obj))
30 die("duplicate replace ref: %s", refname);
31
32 return 0;