Skip to content

Commit 212e0f7

Browse files
stefanbellergitster
authored andcommitted
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>
1 parent 4a6067c commit 212e0f7

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

builtin/replace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ struct show_data {
3939
enum replace_format format;
4040
};
4141

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,
4344
int flag, void *cb_data)
4445
{
4546
struct show_data *data = cb_data;
@@ -56,9 +57,8 @@ static int show_reference(const char *refname, const struct object_id *oid,
5657
if (get_oid(refname, &object))
5758
return error("Failed to resolve '%s' as a valid ref.", refname);
5859

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);
6262

6363
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
6464
oid_to_hex(oid), type_name(repl_type));

refs.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,12 +1474,11 @@ int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
14741474
return do_for_each_ref(refs, prefix, fn, 0, flag, cb_data);
14751475
}
14761476

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)
14781478
{
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);
14831482
}
14841483

14851484
int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)

refs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data,
317317
int for_each_tag_ref(each_ref_fn fn, void *cb_data);
318318
int for_each_branch_ref(each_ref_fn fn, void *cb_data);
319319
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);
321321
int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data);
322322
int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
323323
const char *prefix, void *cb_data);

replace-object.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include "repository.h"
77
#include "commit.h"
88

9-
static int register_replace_ref(const char *refname,
9+
static int register_replace_ref(struct repository *r,
10+
const char *refname,
1011
const struct object_id *oid,
1112
int flag, void *cb_data)
1213
{
@@ -25,7 +26,7 @@ static int register_replace_ref(const char *refname,
2526
oidcpy(&repl_obj->replacement, oid);
2627

2728
/* Register new object */
28-
if (oidmap_put(the_repository->objects->replace_map, repl_obj))
29+
if (oidmap_put(r->objects->replace_map, repl_obj))
2930
die("duplicate replace ref: %s", refname);
3031

3132
return 0;

0 commit comments

Comments
 (0)