aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-17 10:19:04 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-17 10:33:39 -0700
commit30aaff437fddd889ba429b50b96ea4c151c502c5 (patch)
tree21c333bae42ced8e44e48fc106924e47d87c97b1 /builtin
parentrefs: move object peeling into "object.c" (diff)
downloadgit-30aaff437fddd889ba429b50b96ea4c151c502c5.tar.gz
git-30aaff437fddd889ba429b50b96ea4c151c502c5.zip
refs: pass repo when peeling objects
Both `peel_object()` and `peel_iterated_oid()` implicitly rely on `the_repository` to look up objects. Despite the fact that we want to get rid of `the_repository`, it also leads to some restrictions in our ref iterators when trying to retrieve the peeled value for a repository other than `the_repository`. Refactor these functions such that both take a repository as argument and remove the now-unnecessary restrictions. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/describe.c2
-rw-r--r--builtin/gc.c2
-rw-r--r--builtin/pack-objects.c6
-rw-r--r--builtin/repack.c2
-rw-r--r--builtin/show-ref.c2
5 files changed, 7 insertions, 7 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 82aca00c80..e5287eddf2 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -200,7 +200,7 @@ static int get_name(const char *path, const struct object_id *oid,
}
/* Is it annotated? */
- if (!peel_iterated_oid(oid, &peeled)) {
+ if (!peel_iterated_oid(the_repository, oid, &peeled)) {
is_annotated = !oideq(oid, &peeled);
} else {
oidcpy(&peeled, oid);
diff --git a/builtin/gc.c b/builtin/gc.c
index 054fca7835..72bac2554f 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -846,7 +846,7 @@ static int dfs_on_ref(const char *refname UNUSED,
struct commit_list *stack = NULL;
struct commit *commit;
- if (!peel_iterated_oid(oid, &peeled))
+ if (!peel_iterated_oid(the_repository, oid, &peeled))
oid = &peeled;
if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
return 0;
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index cd2396896d..62ddf41f84 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -779,7 +779,7 @@ static int mark_tagged(const char *path UNUSED, const struct object_id *oid,
if (entry)
entry->tagged = 1;
- if (!peel_iterated_oid(oid, &peeled)) {
+ if (!peel_iterated_oid(the_repository, oid, &peeled)) {
entry = packlist_find(&to_pack, &peeled);
if (entry)
entry->tagged = 1;
@@ -3125,7 +3125,7 @@ static int add_ref_tag(const char *tag UNUSED, const struct object_id *oid,
{
struct object_id peeled;
- if (!peel_iterated_oid(oid, &peeled) && obj_is_packed(&peeled))
+ if (!peel_iterated_oid(the_repository, oid, &peeled) && obj_is_packed(&peeled))
add_tag_chain(oid);
return 0;
}
@@ -4074,7 +4074,7 @@ static int mark_bitmap_preferred_tip(const char *refname,
struct object_id peeled;
struct object *object;
- if (!peel_iterated_oid(oid, &peeled))
+ if (!peel_iterated_oid(the_repository, oid, &peeled))
oid = &peeled;
object = parse_object_or_die(oid, refname);
diff --git a/builtin/repack.c b/builtin/repack.c
index 43491a4cbf..58ad82dd97 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -673,7 +673,7 @@ static int midx_snapshot_ref_one(const char *refname UNUSED,
struct midx_snapshot_ref_data *data = _data;
struct object_id peeled;
- if (!peel_iterated_oid(oid, &peeled))
+ if (!peel_iterated_oid(the_repository, oid, &peeled))
oid = &peeled;
if (oidset_insert(&data->seen, oid))
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 151ef35134..3114bdc391 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -50,7 +50,7 @@ static void show_one(const struct show_one_options *opts,
if (!opts->deref_tags)
return;
- if (!peel_iterated_oid(oid, &peeled)) {
+ if (!peel_iterated_oid(the_repository, oid, &peeled)) {
hex = repo_find_unique_abbrev(the_repository, &peeled, opts->abbrev);
printf("%s %s^{}\n", hex, refname);
}