Skip to content

Commit e55f364

Browse files
committed
Merge branch 'ps/refs-without-the-repository-updates' into ps/ref-storage-migration
* 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
2 parents 4365c6f + 0089278 commit e55f364

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+408
-392
lines changed

attr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,8 @@ static const char *builtin_object_mode_attr(struct index_state *istate, const ch
12881288
if (pos >= 0) {
12891289
if (S_ISGITLINK(istate->cache[pos]->ce_mode))
12901290
mode = istate->cache[pos]->ce_mode;
1291-
} else if (resolve_gitlink_ref(path, "HEAD", &oid) == 0) {
1291+
} else if (repo_resolve_gitlink_ref(the_repository, path,
1292+
"HEAD", &oid) == 0) {
12921293
mode = S_IFGITLINK;
12931294
}
12941295
}

builtin/clone.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
14681468
} else if (remote_head) {
14691469
our_head_points_at = NULL;
14701470
} else {
1471+
char *to_free = NULL;
14711472
const char *branch;
14721473

14731474
if (!mapped_refs) {
@@ -1480,7 +1481,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
14801481
"refs/heads/", &branch)) {
14811482
unborn_head = xstrdup(transport_ls_refs_options.unborn_head_target);
14821483
} else {
1483-
branch = git_default_branch_name(0);
1484+
branch = to_free = repo_default_branch_name(the_repository, 0);
14841485
unborn_head = xstrfmt("refs/heads/%s", branch);
14851486
}
14861487

@@ -1496,6 +1497,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
14961497
* a match.
14971498
*/
14981499
our_head_points_at = find_remote_branch(mapped_refs, branch);
1500+
1501+
free(to_free);
14991502
}
15001503

15011504
write_refspec_config(src_ref_prefix, our_head_points_at,

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static int get_name(const char *path, const struct object_id *oid,
200200
}
201201

202202
/* Is it annotated? */
203-
if (!peel_iterated_oid(oid, &peeled)) {
203+
if (!peel_iterated_oid(the_repository, oid, &peeled)) {
204204
is_annotated = !oideq(oid, &peeled);
205205
} else {
206206
oidcpy(&peeled, oid);

builtin/fetch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,8 @@ static int prune_refs(struct display_state *display_state,
14121412
_("(none)"), ref->name,
14131413
&ref->new_oid, &ref->old_oid,
14141414
summary_width);
1415-
warn_dangling_symref(stderr, dangling_msg, ref->name);
1415+
refs_warn_dangling_symref(get_main_ref_store(the_repository),
1416+
stderr, dangling_msg, ref->name);
14161417
}
14171418
}
14181419

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ static int dfs_on_ref(const char *refname UNUSED,
846846
struct commit_list *stack = NULL;
847847
struct commit *commit;
848848

849-
if (!peel_iterated_oid(oid, &peeled))
849+
if (!peel_iterated_oid(the_repository, oid, &peeled))
850850
oid = &peeled;
851851
if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
852852
return 0;

builtin/pack-objects.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static int mark_tagged(const char *path UNUSED, const struct object_id *oid,
779779

780780
if (entry)
781781
entry->tagged = 1;
782-
if (!peel_iterated_oid(oid, &peeled)) {
782+
if (!peel_iterated_oid(the_repository, oid, &peeled)) {
783783
entry = packlist_find(&to_pack, &peeled);
784784
if (entry)
785785
entry->tagged = 1;
@@ -3125,7 +3125,7 @@ static int add_ref_tag(const char *tag UNUSED, const struct object_id *oid,
31253125
{
31263126
struct object_id peeled;
31273127

3128-
if (!peel_iterated_oid(oid, &peeled) && obj_is_packed(&peeled))
3128+
if (!peel_iterated_oid(the_repository, oid, &peeled) && obj_is_packed(&peeled))
31293129
add_tag_chain(oid);
31303130
return 0;
31313131
}
@@ -4074,7 +4074,7 @@ static int mark_bitmap_preferred_tip(const char *refname,
40744074
struct object_id peeled;
40754075
struct object *object;
40764076

4077-
if (!peel_iterated_oid(oid, &peeled))
4077+
if (!peel_iterated_oid(the_repository, oid, &peeled))
40784078
oid = &peeled;
40794079

40804080
object = parse_object_or_die(oid, refname);

builtin/reflog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
378378
char *ref;
379379
struct expire_reflog_policy_cb cb = { .cmd = cmd };
380380

381-
if (!dwim_log(argv[i], strlen(argv[i]), NULL, &ref)) {
381+
if (!repo_dwim_log(the_repository, argv[i], strlen(argv[i]), NULL, &ref)) {
382382
status |= error(_("%s points nowhere!"), argv[i]);
383383
continue;
384384
}

builtin/remote.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,8 @@ static int prune_remote(const char *remote, int dry_run)
14771477
abbrev_ref(refname, "refs/remotes/"));
14781478
}
14791479

1480-
warn_dangling_symrefs(stdout, dangling_msg, &refs_to_prune);
1480+
refs_warn_dangling_symrefs(get_main_ref_store(the_repository),
1481+
stdout, dangling_msg, &refs_to_prune);
14811482

14821483
string_list_clear(&refs_to_prune, 0);
14831484
free_remote_ref_states(&states);

builtin/repack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,
673673
struct midx_snapshot_ref_data *data = _data;
674674
struct object_id peeled;
675675

676-
if (!peel_iterated_oid(oid, &peeled))
676+
if (!peel_iterated_oid(the_repository, oid, &peeled))
677677
oid = &peeled;
678678

679679
if (oidset_insert(&data->seen, oid))

builtin/replace.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ enum replace_format {
4343
};
4444

4545
struct show_data {
46+
struct repository *repo;
4647
const char *pattern;
4748
enum replace_format format;
4849
};
4950

50-
static int show_reference(struct repository *r, const char *refname,
51+
static int show_reference(const char *refname,
5152
const struct object_id *oid,
5253
int flag UNUSED, void *cb_data)
5354
{
@@ -62,11 +63,11 @@ static int show_reference(struct repository *r, const char *refname,
6263
struct object_id object;
6364
enum object_type obj_type, repl_type;
6465

65-
if (repo_get_oid(r, refname, &object))
66+
if (repo_get_oid(data->repo, refname, &object))
6667
return error(_("failed to resolve '%s' as a valid ref"), refname);
6768

68-
obj_type = oid_object_info(r, &object, NULL);
69-
repl_type = oid_object_info(r, oid, NULL);
69+
obj_type = oid_object_info(data->repo, &object, NULL);
70+
repl_type = oid_object_info(data->repo, oid, NULL);
7071

7172
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
7273
oid_to_hex(oid), type_name(repl_type));
@@ -80,6 +81,7 @@ static int list_replace_refs(const char *pattern, const char *format)
8081
{
8182
struct show_data data;
8283

84+
data.repo = the_repository;
8385
if (!pattern)
8486
pattern = "*";
8587
data.pattern = pattern;
@@ -99,7 +101,8 @@ static int list_replace_refs(const char *pattern, const char *format)
99101
"valid formats are 'short', 'medium' and 'long'"),
100102
format);
101103

102-
for_each_replace_ref(the_repository, show_reference, (void *)&data);
104+
refs_for_each_replace_ref(get_main_ref_store(the_repository),
105+
show_reference, (void *)&data);
103106

104107
return 0;
105108
}

0 commit comments

Comments
 (0)