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>
This commit is contained in:
committed by
Junio C Hamano
parent
4a6067cda5
commit
212e0f7efe
@@ -39,7 +39,8 @@ struct show_data {
|
|||||||
enum replace_format format;
|
enum replace_format format;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int show_reference(const char *refname, const struct object_id *oid,
|
static int show_reference(struct repository *r, const char *refname,
|
||||||
|
const struct object_id *oid,
|
||||||
int flag, void *cb_data)
|
int flag, void *cb_data)
|
||||||
{
|
{
|
||||||
struct show_data *data = cb_data;
|
struct show_data *data = cb_data;
|
||||||
@@ -56,9 +57,8 @@ static int show_reference(const char *refname, const struct object_id *oid,
|
|||||||
if (get_oid(refname, &object))
|
if (get_oid(refname, &object))
|
||||||
return error("Failed to resolve '%s' as a valid ref.", refname);
|
return error("Failed to resolve '%s' as a valid ref.", refname);
|
||||||
|
|
||||||
obj_type = oid_object_info(the_repository, &object,
|
obj_type = oid_object_info(r, &object, NULL);
|
||||||
NULL);
|
repl_type = oid_object_info(r, oid, NULL);
|
||||||
repl_type = oid_object_info(the_repository, oid, NULL);
|
|
||||||
|
|
||||||
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
|
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
|
||||||
oid_to_hex(oid), type_name(repl_type));
|
oid_to_hex(oid), type_name(repl_type));
|
||||||
|
|||||||
9
refs.c
9
refs.c
@@ -1474,12 +1474,11 @@ int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
|
|||||||
return do_for_each_ref(refs, prefix, fn, 0, flag, cb_data);
|
return do_for_each_ref(refs, prefix, fn, 0, flag, cb_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int for_each_replace_ref(struct repository *r, each_ref_fn fn, void *cb_data)
|
int for_each_replace_ref(struct repository *r, each_repo_ref_fn fn, void *cb_data)
|
||||||
{
|
{
|
||||||
return do_for_each_ref(get_main_ref_store(r),
|
return do_for_each_repo_ref(r, git_replace_ref_base, fn,
|
||||||
git_replace_ref_base, fn,
|
strlen(git_replace_ref_base),
|
||||||
strlen(git_replace_ref_base),
|
DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
|
||||||
DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)
|
int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)
|
||||||
|
|||||||
2
refs.h
2
refs.h
@@ -317,7 +317,7 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data,
|
|||||||
int for_each_tag_ref(each_ref_fn fn, void *cb_data);
|
int for_each_tag_ref(each_ref_fn fn, void *cb_data);
|
||||||
int for_each_branch_ref(each_ref_fn fn, void *cb_data);
|
int for_each_branch_ref(each_ref_fn fn, void *cb_data);
|
||||||
int for_each_remote_ref(each_ref_fn fn, void *cb_data);
|
int for_each_remote_ref(each_ref_fn fn, void *cb_data);
|
||||||
int for_each_replace_ref(struct repository *r, each_ref_fn fn, void *cb_data);
|
int for_each_replace_ref(struct repository *r, each_repo_ref_fn fn, void *cb_data);
|
||||||
int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data);
|
int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data);
|
||||||
int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
|
int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
|
||||||
const char *prefix, void *cb_data);
|
const char *prefix, void *cb_data);
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
#include "repository.h"
|
#include "repository.h"
|
||||||
#include "commit.h"
|
#include "commit.h"
|
||||||
|
|
||||||
static int register_replace_ref(const char *refname,
|
static int register_replace_ref(struct repository *r,
|
||||||
|
const char *refname,
|
||||||
const struct object_id *oid,
|
const struct object_id *oid,
|
||||||
int flag, void *cb_data)
|
int flag, void *cb_data)
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,7 @@ static int register_replace_ref(const char *refname,
|
|||||||
oidcpy(&repl_obj->replacement, oid);
|
oidcpy(&repl_obj->replacement, oid);
|
||||||
|
|
||||||
/* Register new object */
|
/* Register new object */
|
||||||
if (oidmap_put(the_repository->objects->replace_map, repl_obj))
|
if (oidmap_put(r->objects->replace_map, repl_obj))
|
||||||
die("duplicate replace ref: %s", refname);
|
die("duplicate replace ref: %s", refname);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user