Re: [PATCH GSoC v2 4/6] fetch-object-info: parse type from server response
Junio C Hamano <[email protected]> Sun, 02 Aug 2026 09:24:13 -0700
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
"Pablo Sabater" <[email protected]> writes: > What I understood is that fetch_object_info shouldn't use object_info to > store the results, because it doesn't call read_object_info() like other > commands like 'info' do. Then, it should use its own data structure to > hold the results with flags like wants_size and wants_type. Something > like: > > struct object_info_results { > enum object_type *types; > size_t *sizes; > unsigned *unrecognized; > size_t nr; > unsigned wants_size:1; > unsigned wants_type:1; > }; I would have expected this to be an array of struct, i.e. struct { struct oid *oid; enum object_type type; size_t size; } *result; size_t result_nr, result_alloc; if you do not have the number of things you query upfront, or it may be an array of fixed size (i.e. no nr/alloc, just nr). If you'll be making the same query for many different objects, you know if you are asking for type for all of them or for none of them, so depending on how the caller uses it, you may not need the valid bit. Or type==OBJ_NONE could signal "we have no info". And you'd be using the second pattern I outlined, i.e. for (size_t it = 0; it < result_nr; it++) { /* * you may selectively populate the oi to signal * you do not need some values, but you get the * idea. */ struct object_info oi = { type_p = &result[it].type, size_p = &result[it].size, ... }; ... ask about result[it].oid using &oi ... } to populate the result[] array with values, I would imagine.