diff options
| author | Jeff King <peff@peff.net> | 2026-08-08 02:02:21 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-08-07 18:50:08 -0700 |
| commit | 567e62b1b946407224dedfb85f8c9220983a5e13 (patch) | |
| tree | d6c3e35a55d49b2269f58b59900d42030a43fbfd /t/t4013/diff.diff_initial..side | |
| parent | 50dd6d370cd6421b523347ffa94bdd35bd264833 (diff) | |
transport: drop remote object-info fields from transport struct
A remote object-info request needs three things: the transport for
contacting the remote, the list of oids to request, and a place to store
the output.
Rather than take these as function parameters, we take only the
transport object, and expect the caller to have placed the other two
into special fields in the transport struct. But this doesn't make much
sense. The set of oids and results are really only valid for one
request. There is no reason the transport would need to hang on to them
outside of the single function call.
Even though we save a few lines passing the parameters around through
the various vtable functions, the result is harder to understand (for
example, who is responsible for cleaning up results, and when should it
happen?). It also opens up the possibility of a subtle bug. A caller is
likely to point those fields to stack variables which could go out of
scope, and the transport struct would be left holding invalid pointers.
This is mostly harmless now, as we disconnect the transport immediately
after the sole caller of transport_fetch_object_info(). But conceptually
we could keep the transport open and make multiple fetch calls (and
reuse the same connection to the helper, to a remote HTTP server, and so
on).
So let's pull these out of the struct and pass them as function
parameters. It's a little more verbose, but I think more clearly
illustrates the intent. I've also tweaked a few function signatures to
mark the input oid array as const, since it is purely an input to the
function.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4013/diff.diff_initial..side')
0 files changed, 0 insertions, 0 deletions
