Skip to content

Commit a6e65fb

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9fd512c commit a6e65fb

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

fetch-pack.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,
115115
cb(negotiator, cache.items[i]);
116116
}
117117

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)
120122
{
121-
enum object_type type;
122-
struct object_info info = { .typep = &type };
123+
struct object_info info = { .typep = type };
123124
struct commit *commit;
124125

125126
commit = lookup_commit_in_graph(the_repository, oid);
@@ -128,9 +129,9 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
128129

129130
while (1) {
130131
if (oid_object_info_extended(the_repository, oid, &info,
131-
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
132+
oi_flags))
132133
return NULL;
133-
if (type == OBJ_TAG) {
134+
if (*type == OBJ_TAG) {
134135
struct tag *tag = (struct tag *)
135136
parse_object(the_repository, oid);
136137

@@ -144,7 +145,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
144145
}
145146
}
146147

147-
if (type == OBJ_COMMIT) {
148+
if (*type == OBJ_COMMIT) {
148149
struct commit *commit = lookup_commit(the_repository, oid);
149150
if (!commit || repo_parse_commit(the_repository, commit))
150151
return NULL;
@@ -154,6 +155,16 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
154155
return NULL;
155156
}
156157

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+
157168
static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
158169
const struct object_id *oid)
159170
{

0 commit comments

Comments
 (0)