streaming: rename `git_istream` into `odb_read_stream`

In the following patches we are about to make the `git_istream` more generic so that it becomes fully controlled by the specific object source that wants to create it. As part of these refactorings we'll fully move the structure into the object database subsystem. Prepare for this change by renaming the structure from `git_istream` to `odb_read_stream`. This mirrors the `odb_write_stream` structure that we already have. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Nov 23, 2025 at 19:59 UTC 6bdda3a3b00fff9a1d64d1bb4732f0c446d7012c
7 files changed +43 -43
archive-tar.c
+1 -1
@@ -129,7 +129,7 @@ static void write_trailer(void)
129 */
130 static int stream_blocked(struct repository *r, const struct object_id *oid)
131 {
132 - struct git_istream *st;
132 + struct odb_read_stream *st;
133 enum object_type type;
134 unsigned long sz;
135 char buf[BLOCKSIZE];
archive-zip.c
+1 -1
@@ -309,7 +309,7 @@ static int write_zip_entry(struct archiver_args *args,
309 enum zip_method method;
310 unsigned char *out;
311 void *deflated = NULL;
312 - struct git_istream *stream = NULL;
312 + struct odb_read_stream *stream = NULL;
313 unsigned long flags = 0;
314 int is_binary = -1;
315 const char *path_without_prefix = path + args->baselen;
builtin/index-pack.c
+1 -1
@@ -762,7 +762,7 @@ static void find_ref_delta_children(const struct object_id *oid,
762
763 struct compare_data {
764 struct object_entry *entry;
765 - struct git_istream *st;
765 + struct odb_read_stream *st;
766 unsigned char *buf;
767 unsigned long buf_size;
768 };
builtin/pack-objects.c
+2 -2
@@ -404,7 +404,7 @@ static unsigned long do_compress(void **pptr, unsigned long size)
404 return stream.total_out;
405 }
406
407 -static unsigned long write_large_blob_data(struct git_istream *st, struct hashfile *f,
407 +static unsigned long write_large_blob_data(struct odb_read_stream *st, struct hashfile *f,
408 const struct object_id *oid)
409 {
410 git_zstream stream;
@@ -513,7 +513,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
513 unsigned hdrlen;
514 enum object_type type;
515 void *buf;
516 - struct git_istream *st = NULL;
516 + struct odb_read_stream *st = NULL;
517 const unsigned hashsz = the_hash_algo->rawsz;
518
519 if (!usable_delta) {
object-file.c
+1 -1
@@ -134,7 +134,7 @@ int stream_object_signature(struct repository *r, const struct object_id *oid)
134 struct object_id real_oid;
135 unsigned long size;
136 enum object_type obj_type;
137 - struct git_istream *st;
137 + struct odb_read_stream *st;
138 struct git_hash_ctx c;
139 char hdr[MAX_HEADER_LEN];
140 int hdrlen;
streaming.c
+31 -31
@@ -14,17 +14,17 @@
14 #include "replace-object.h"
15 #include "packfile.h"
16
17 -typedef int (*open_istream_fn)(struct git_istream *,
17 +typedef int (*open_istream_fn)(struct odb_read_stream *,
18 struct repository *,
19 const struct object_id *,
20 enum object_type *);
21 -typedef int (*close_istream_fn)(struct git_istream *);
22 -typedef ssize_t (*read_istream_fn)(struct git_istream *, char *, size_t);
21 +typedef int (*close_istream_fn)(struct odb_read_stream *);
22 +typedef ssize_t (*read_istream_fn)(struct odb_read_stream *, char *, size_t);
23
24 #define FILTER_BUFFER (1024*16)
25
26 struct filtered_istream {
27 - struct git_istream *upstream;
27 + struct odb_read_stream *upstream;
28 struct stream_filter *filter;
29 char ibuf[FILTER_BUFFER];
30 char obuf[FILTER_BUFFER];
@@ -33,7 +33,7 @@ struct filtered_istream {
33 int input_finished;
34 };
35
36 -struct git_istream {
36 +struct odb_read_stream {
37 open_istream_fn open;
38 close_istream_fn close;
39 read_istream_fn read;
@@ -71,7 +71,7 @@ struct git_istream {
71 *
72 *****************************************************************/
73
74 -static void close_deflated_stream(struct git_istream *st)
74 +static void close_deflated_stream(struct odb_read_stream *st)
75 {
76 if (st->z_state == z_used)
77 git_inflate_end(&st->z);
@@ -84,13 +84,13 @@ static void close_deflated_stream(struct git_istream *st)
84 *
85 *****************************************************************/
86
87 -static int close_istream_filtered(struct git_istream *st)
87 +static int close_istream_filtered(struct odb_read_stream *st)
88 {
89 free_stream_filter(st->u.filtered.filter);
90 return close_istream(st->u.filtered.upstream);
91 }
92
93 -static ssize_t read_istream_filtered(struct git_istream *st, char *buf,
93 +static ssize_t read_istream_filtered(struct odb_read_stream *st, char *buf,
94 size_t sz)
95 {
96 struct filtered_istream *fs = &(st->u.filtered);
@@ -150,10 +150,10 @@ static ssize_t read_istream_filtered(struct git_istream *st, char *buf,
150 return filled;
151 }
152
153 -static struct git_istream *attach_stream_filter(struct git_istream *st,
154 - struct stream_filter *filter)
153 +static struct odb_read_stream *attach_stream_filter(struct odb_read_stream *st,
154 + struct stream_filter *filter)
155 {
156 - struct git_istream *ifs = xmalloc(sizeof(*ifs));
156 + struct odb_read_stream *ifs = xmalloc(sizeof(*ifs));
157 struct filtered_istream *fs = &(ifs->u.filtered);
158
159 ifs->close = close_istream_filtered;
@@ -173,7 +173,7 @@ static struct git_istream *attach_stream_filter(struct git_istream *st,
173 *
174 *****************************************************************/
175
176 -static ssize_t read_istream_loose(struct git_istream *st, char *buf, size_t sz)
176 +static ssize_t read_istream_loose(struct odb_read_stream *st, char *buf, size_t sz)
177 {
178 size_t total_read = 0;
179
@@ -218,14 +218,14 @@ static ssize_t read_istream_loose(struct git_istream *st, char *buf, size_t sz)
218 return total_read;
219 }
220
221 -static int close_istream_loose(struct git_istream *st)
221 +static int close_istream_loose(struct odb_read_stream *st)
222 {
223 close_deflated_stream(st);
224 munmap(st->u.loose.mapped, st->u.loose.mapsize);
225 return 0;
226 }
227
228 -static int open_istream_loose(struct git_istream *st, struct repository *r,
228 +static int open_istream_loose(struct odb_read_stream *st, struct repository *r,
229 const struct object_id *oid,
230 enum object_type *type)
231 {
@@ -277,7 +277,7 @@ error:
277 *
278 *****************************************************************/
279
280 -static ssize_t read_istream_pack_non_delta(struct git_istream *st, char *buf,
280 +static ssize_t read_istream_pack_non_delta(struct odb_read_stream *st, char *buf,
281 size_t sz)
282 {
283 size_t total_read = 0;
@@ -336,13 +336,13 @@ static ssize_t read_istream_pack_non_delta(struct git_istream *st, char *buf,
336 return total_read;
337 }
338
339 -static int close_istream_pack_non_delta(struct git_istream *st)
339 +static int close_istream_pack_non_delta(struct odb_read_stream *st)
340 {
341 close_deflated_stream(st);
342 return 0;
343 }
344
345 -static int open_istream_pack_non_delta(struct git_istream *st,
345 +static int open_istream_pack_non_delta(struct odb_read_stream *st,
346 struct repository *r UNUSED,
347 const struct object_id *oid UNUSED,
348 enum object_type *type UNUSED)
@@ -380,13 +380,13 @@ static int open_istream_pack_non_delta(struct git_istream *st,
380 *
381 *****************************************************************/
382
383 -static int close_istream_incore(struct git_istream *st)
383 +static int close_istream_incore(struct odb_read_stream *st)
384 {
385 free(st->u.incore.buf);
386 return 0;
387 }
388
389 -static ssize_t read_istream_incore(struct git_istream *st, char *buf, size_t sz)
389 +static ssize_t read_istream_incore(struct odb_read_stream *st, char *buf, size_t sz)
390 {
391 size_t read_size = sz;
392 size_t remainder = st->size - st->u.incore.read_ptr;
@@ -400,7 +400,7 @@ static ssize_t read_istream_incore(struct git_istream *st, char *buf, size_t sz)
400 return read_size;
401 }
402
403 -static int open_istream_incore(struct git_istream *st, struct repository *r,
403 +static int open_istream_incore(struct odb_read_stream *st, struct repository *r,
404 const struct object_id *oid, enum object_type *type)
405 {
406 struct object_info oi = OBJECT_INFO_INIT;
@@ -420,7 +420,7 @@ static int open_istream_incore(struct git_istream *st, struct repository *r,
420 * static helpers variables and functions for users of streaming interface
421 *****************************************************************************/
422
423 -static int istream_source(struct git_istream *st,
423 +static int istream_source(struct odb_read_stream *st,
424 struct repository *r,
425 const struct object_id *oid,
426 enum object_type *type)
@@ -458,25 +458,25 @@ static int istream_source(struct git_istream *st,
458 * Users of streaming interface
459 ****************************************************************/
460
461 -int close_istream(struct git_istream *st)
461 +int close_istream(struct odb_read_stream *st)
462 {
463 int r = st->close(st);
464 free(st);
465 return r;
466 }
467
468 -ssize_t read_istream(struct git_istream *st, void *buf, size_t sz)
468 +ssize_t read_istream(struct odb_read_stream *st, void *buf, size_t sz)
469 {
470 return st->read(st, buf, sz);
471 }
472
473 -struct git_istream *open_istream(struct repository *r,
474 - const struct object_id *oid,
475 - enum object_type *type,
476 - unsigned long *size,
477 - struct stream_filter *filter)
473 +struct odb_read_stream *open_istream(struct repository *r,
474 + const struct object_id *oid,
475 + enum object_type *type,
476 + unsigned long *size,
477 + struct stream_filter *filter)
478 {
479 - struct git_istream *st = xmalloc(sizeof(*st));
479 + struct odb_read_stream *st = xmalloc(sizeof(*st));
480 const struct object_id *real = lookup_replace_object(r, oid);
481 int ret = istream_source(st, r, real, type);
482
@@ -493,7 +493,7 @@ struct git_istream *open_istream(struct repository *r,
493 }
494 if (filter) {
495 /* Add "&& !is_null_stream_filter(filter)" for performance */
496 - struct git_istream *nst = attach_stream_filter(st, filter);
496 + struct odb_read_stream *nst = attach_stream_filter(st, filter);
497 if (!nst) {
498 close_istream(st);
499 return NULL;
@@ -508,7 +508,7 @@ struct git_istream *open_istream(struct repository *r,
508 int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter *filter,
509 int can_seek)
510 {
511 - struct git_istream *st;
511 + struct odb_read_stream *st;
512 enum object_type type;
513 unsigned long sz;
514 ssize_t kept = 0;
streaming.h
+6 -6
@@ -7,14 +7,14 @@
7 #include "object.h"
8
9 /* opaque */
10 -struct git_istream;
10 +struct odb_read_stream;
11 struct stream_filter;
12
13 -struct git_istream *open_istream(struct repository *, const struct object_id *,
14 - enum object_type *, unsigned long *,
15 - struct stream_filter *);
16 -int close_istream(struct git_istream *);
17 -ssize_t read_istream(struct git_istream *, void *, size_t);
13 +struct odb_read_stream *open_istream(struct repository *, const struct object_id *,
14 + enum object_type *, unsigned long *,
15 + struct stream_filter *);
16 +int close_istream(struct odb_read_stream *);
17 +ssize_t read_istream(struct odb_read_stream *, void *, size_t);
18
19 int stream_blob_to_fd(int fd, const struct object_id *, struct stream_filter *, int can_seek);
20