Merge branch 'ps/refs-without-the-repository-updates'
Further clean-up the refs subsystem to stop relying on the_repository, and instead use the repository associated to the ref_store object. * ps/refs-without-the-repository-updates: refs/packed: remove references to `the_hash_algo` refs/files: remove references to `the_hash_algo` refs/files: use correct repository refs: remove `dwim_log()` refs: drop `git_default_branch_name()` refs: pass repo when peeling objects refs: move object peeling into "object.c" refs: pass ref store when detecting dangling symrefs refs: convert iteration over replace refs to accept ref store refs: retrieve worktree ref stores via associated repository refs: refactor `resolve_gitlink_ref()` to accept a repository refs: pass repo when retrieving submodule ref store refs: track ref stores via strmap refs: implement releasing ref storages refs: rename `init_db` callback to avoid confusion refs: adjust names for `init` and `init_db` callbacks
This commit is contained in:
@ -43,11 +43,12 @@ enum replace_format {
|
||||
};
|
||||
|
||||
struct show_data {
|
||||
struct repository *repo;
|
||||
const char *pattern;
|
||||
enum replace_format format;
|
||||
};
|
||||
|
||||
static int show_reference(struct repository *r, const char *refname,
|
||||
static int show_reference(const char *refname,
|
||||
const struct object_id *oid,
|
||||
int flag UNUSED, void *cb_data)
|
||||
{
|
||||
@ -62,11 +63,11 @@ static int show_reference(struct repository *r, const char *refname,
|
||||
struct object_id object;
|
||||
enum object_type obj_type, repl_type;
|
||||
|
||||
if (repo_get_oid(r, refname, &object))
|
||||
if (repo_get_oid(data->repo, refname, &object))
|
||||
return error(_("failed to resolve '%s' as a valid ref"), refname);
|
||||
|
||||
obj_type = oid_object_info(r, &object, NULL);
|
||||
repl_type = oid_object_info(r, oid, NULL);
|
||||
obj_type = oid_object_info(data->repo, &object, NULL);
|
||||
repl_type = oid_object_info(data->repo, oid, NULL);
|
||||
|
||||
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
|
||||
oid_to_hex(oid), type_name(repl_type));
|
||||
@ -80,6 +81,7 @@ static int list_replace_refs(const char *pattern, const char *format)
|
||||
{
|
||||
struct show_data data;
|
||||
|
||||
data.repo = the_repository;
|
||||
if (!pattern)
|
||||
pattern = "*";
|
||||
data.pattern = pattern;
|
||||
@ -99,7 +101,8 @@ static int list_replace_refs(const char *pattern, const char *format)
|
||||
"valid formats are 'short', 'medium' and 'long'"),
|
||||
format);
|
||||
|
||||
for_each_replace_ref(the_repository, show_reference, (void *)&data);
|
||||
refs_for_each_replace_ref(get_main_ref_store(the_repository),
|
||||
show_reference, (void *)&data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user