fetch-pack: add a deref_without_lazy_fetch_extended()

Add a version of the deref_without_lazy_fetch function which can be called with custom oi_flags and to grab information about the "object_type". This will be used for the bundle-uri client in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed May 16, 2022 at 20:11 UTC a6e65fb39caf18259c660c1c7910d5bf80bc15cb
1 file changed +18 -7
fetch-pack.c
+18 -7
@@ -115,11 +115,12 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,
115 cb(negotiator, cache.items[i]);
116 }
117
118 -static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
119 - int mark_tags_complete)
118 +static struct commit *deref_without_lazy_fetch_extended(const struct object_id *oid,
119 + int mark_tags_complete,
120 + enum object_type *type,
121 + unsigned int oi_flags)
122 {
121 - enum object_type type;
122 - struct object_info info = { .typep = &type };
123 + struct object_info info = { .typep = type };
124 struct commit *commit;
125
126 commit = lookup_commit_in_graph(the_repository, oid);
@@ -128,9 +129,9 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
129
130 while (1) {
131 if (oid_object_info_extended(the_repository, oid, &info,
131 - OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
132 + oi_flags))
133 return NULL;
133 - if (type == OBJ_TAG) {
134 + if (*type == OBJ_TAG) {
135 struct tag *tag = (struct tag *)
136 parse_object(the_repository, oid);
137
@@ -144,7 +145,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
145 }
146 }
147
147 - if (type == OBJ_COMMIT) {
148 + if (*type == OBJ_COMMIT) {
149 struct commit *commit = lookup_commit(the_repository, oid);
150 if (!commit || repo_parse_commit(the_repository, commit))
151 return NULL;
@@ -154,6 +155,16 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
155 return NULL;
156 }
157
158 +
159 +static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
160 + int mark_tags_complete)
161 +{
162 + enum object_type type;
163 + unsigned flags = OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK;
164 + return deref_without_lazy_fetch_extended(oid, mark_tags_complete,
165 + &type, flags);
166 +}
167 +
168 static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
169 const struct object_id *oid)
170 {