Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
01f9010
Merge branch 'ps/object-source-loose' into ps/object-read-stream
gitster Nov 19, 2025
42aa760
win32: pthread_cond_init should return a value
AZero13 Nov 20, 2025
6bdda3a
streaming: rename `git_istream` into `odb_read_stream`
pks-t Nov 23, 2025
70c8b5f
streaming: drop the `open()` callback function
pks-t Nov 23, 2025
3f64dea
streaming: propagate final object type via the stream
pks-t Nov 23, 2025
3c7722d
streaming: explicitly pass packfile info when streaming a packed object
pks-t Nov 23, 2025
595296e
streaming: allocate stream inside the backend-specific logic
pks-t Nov 23, 2025
e030d0a
streaming: create structure for in-core object streams
pks-t Nov 23, 2025
b7774c0
streaming: create structure for loose object streams
pks-t Nov 23, 2025
5f0d8d2
streaming: create structure for packed object streams
pks-t Nov 23, 2025
1154b2d
streaming: create structure for filtered object streams
pks-t Nov 23, 2025
eb5abbb
streaming: move zlib stream into backends
pks-t Nov 23, 2025
385e188
packfile: introduce function to read object info from a store
pks-t Nov 23, 2025
4c89d31
streaming: rely on object sources to create object stream
pks-t Nov 23, 2025
c26da34
streaming: get rid of `the_repository`
pks-t Nov 23, 2025
ffc9a34
streaming: make the `odb_read_stream` definition public
pks-t Nov 23, 2025
bc30a2f
streaming: move logic to read loose objects streams into backend
pks-t Nov 23, 2025
8c1b84b
streaming: move logic to read packed objects streams into backend
pks-t Nov 23, 2025
378ec56
streaming: refactor interface to be object-database-centric
pks-t Nov 23, 2025
1599b68
streaming: move into object database subsystem
pks-t Nov 23, 2025
7b94028
streaming: drop redundant type and size pointers
pks-t Nov 23, 2025
e1ecf0d
wrapper: add git_mkdtemp()
rscharfe Dec 6, 2025
5ecd359
compat: use git_mkdtemp()
rscharfe Dec 6, 2025
47bf147
compat: remove mingw_mktemp()
rscharfe Dec 6, 2025
7bef658
banned.h: ban mktemp(3)
rscharfe Dec 6, 2025
10bba53
compat: remove gitmkdtemp()
rscharfe Dec 6, 2025
dbe5427
Merge branch 'ps/object-read-stream'
gitster Dec 16, 2025
72154ce
Merge branch 'gf/win32-pthread-cond-init'
gitster Dec 16, 2025
91bfbf4
Merge branch 'rs/ban-mktemp'
gitster Dec 16, 2025
e7ef0ca
The ninth batch
gitster Dec 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Documentation/RelNotes/2.53.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ Performance, Internal Implementation, Development Support etc.
"git diff --find-copioes-harder", also making the operation run
faster.

* The "git_istream" abstraction has been revamped to make it easier
to interface with pluggable object database design.

* Rewrite the only use of "mktemp()" that is subject to TOCTOU race
and Stop using the insecure "mktemp()" function.
(merge 10bba537c4 rs/ban-mktemp later to maint).


Fixes since v2.52
-----------------
Expand Down Expand Up @@ -167,6 +174,9 @@ Fixes since v2.52
pathspec, which has been corrected.
(merge 05491b90ce js/last-modified-with-sparse-checkouts later to maint).

* Emulation code clean-up.
(merge 42aa7603aa gf/win32-pthread-cond-init later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge 46207a54cc qj/doc-http-bad-want-response later to maint).
(merge df90eccd93 kh/doc-commit-extra-references later to maint).
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ LIB_OBJS += object-file.o
LIB_OBJS += object-name.o
LIB_OBJS += object.o
LIB_OBJS += odb.o
LIB_OBJS += odb/streaming.o
LIB_OBJS += oid-array.o
LIB_OBJS += oidmap.o
LIB_OBJS += oidset.o
Expand Down Expand Up @@ -1294,7 +1295,6 @@ LIB_OBJS += split-index.o
LIB_OBJS += stable-qsort.o
LIB_OBJS += statinfo.o
LIB_OBJS += strbuf.o
LIB_OBJS += streaming.o
LIB_OBJS += string-list.o
LIB_OBJS += strmap.o
LIB_OBJS += strvec.o
Expand Down Expand Up @@ -1919,7 +1919,6 @@ ifdef NO_SETENV
endif
ifdef NO_MKDTEMP
COMPAT_CFLAGS += -DNO_MKDTEMP
COMPAT_OBJS += compat/mkdtemp.o
endif
ifdef MKDIR_WO_TRAILING_SLASH
COMPAT_CFLAGS += -DMKDIR_WO_TRAILING_SLASH
Expand Down
12 changes: 5 additions & 7 deletions archive-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "tar.h"
#include "archive.h"
#include "odb.h"
#include "odb/streaming.h"
#include "strbuf.h"
#include "streaming.h"
#include "run-command.h"
#include "write-or-die.h"

Expand Down Expand Up @@ -129,22 +129,20 @@ static void write_trailer(void)
*/
static int stream_blocked(struct repository *r, const struct object_id *oid)
{
struct git_istream *st;
enum object_type type;
unsigned long sz;
struct odb_read_stream *st;
char buf[BLOCKSIZE];
ssize_t readlen;

st = open_istream(r, oid, &type, &sz, NULL);
st = odb_read_stream_open(r->objects, oid, NULL);
if (!st)
return error(_("cannot stream blob %s"), oid_to_hex(oid));
for (;;) {
readlen = read_istream(st, buf, sizeof(buf));
readlen = odb_read_stream_read(st, buf, sizeof(buf));
if (readlen <= 0)
break;
do_write_blocked(buf, readlen);
}
close_istream(st);
odb_read_stream_close(st);
if (!readlen)
finish_record();
return readlen;
Expand Down
17 changes: 8 additions & 9 deletions archive-zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "gettext.h"
#include "git-zlib.h"
#include "hex.h"
#include "streaming.h"
#include "utf8.h"
#include "odb.h"
#include "odb/streaming.h"
#include "strbuf.h"
#include "userdiff.h"
#include "write-or-die.h"
Expand Down Expand Up @@ -309,7 +309,7 @@ static int write_zip_entry(struct archiver_args *args,
enum zip_method method;
unsigned char *out;
void *deflated = NULL;
struct git_istream *stream = NULL;
struct odb_read_stream *stream = NULL;
unsigned long flags = 0;
int is_binary = -1;
const char *path_without_prefix = path + args->baselen;
Expand Down Expand Up @@ -347,12 +347,11 @@ static int write_zip_entry(struct archiver_args *args,
method = ZIP_METHOD_DEFLATE;

if (!buffer) {
enum object_type type;
stream = open_istream(args->repo, oid, &type, &size,
NULL);
stream = odb_read_stream_open(args->repo->objects, oid, NULL);
if (!stream)
return error(_("cannot stream blob %s"),
oid_to_hex(oid));
size = stream->size;
flags |= ZIP_STREAM;
out = NULL;
} else {
Expand Down Expand Up @@ -429,7 +428,7 @@ static int write_zip_entry(struct archiver_args *args,
ssize_t readlen;

for (;;) {
readlen = read_istream(stream, buf, sizeof(buf));
readlen = odb_read_stream_read(stream, buf, sizeof(buf));
if (readlen <= 0)
break;
crc = crc32(crc, buf, readlen);
Expand All @@ -439,7 +438,7 @@ static int write_zip_entry(struct archiver_args *args,
buf, readlen);
write_or_die(1, buf, readlen);
}
close_istream(stream);
odb_read_stream_close(stream);
if (readlen)
return readlen;

Expand All @@ -462,7 +461,7 @@ static int write_zip_entry(struct archiver_args *args,
zstream.avail_out = sizeof(compressed);

for (;;) {
readlen = read_istream(stream, buf, sizeof(buf));
readlen = odb_read_stream_read(stream, buf, sizeof(buf));
if (readlen <= 0)
break;
crc = crc32(crc, buf, readlen);
Expand All @@ -486,7 +485,7 @@ static int write_zip_entry(struct archiver_args *args,
}

}
close_istream(stream);
odb_read_stream_close(stream);
if (readlen)
return readlen;

Expand Down
3 changes: 3 additions & 0 deletions banned.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@
#undef asctime_r
#define asctime_r(t, buf) BANNED(asctime_r)

#undef mktemp
#define mktemp(x) BANNED(mktemp)

#endif /* BANNED_H */
4 changes: 2 additions & 2 deletions builtin/cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#include "list-objects-filter-options.h"
#include "parse-options.h"
#include "userdiff.h"
#include "streaming.h"
#include "oid-array.h"
#include "packfile.h"
#include "pack-bitmap.h"
#include "object-file.h"
#include "object-name.h"
#include "odb.h"
#include "odb/streaming.h"
#include "replace-object.h"
#include "promisor-remote.h"
#include "mailmap.h"
Expand Down Expand Up @@ -95,7 +95,7 @@ static int filter_object(const char *path, unsigned mode,

static int stream_blob(const struct object_id *oid)
{
if (stream_blob_to_fd(1, oid, NULL, 0))
if (odb_stream_blob_to_fd(the_repository->objects, 1, oid, NULL, 0))
die("unable to stream %s to stdout", oid_to_hex(oid));
return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions builtin/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#include "fsck.h"
#include "parse-options.h"
#include "progress.h"
#include "streaming.h"
#include "packfile.h"
#include "object-file.h"
#include "object-name.h"
#include "odb.h"
#include "odb/streaming.h"
#include "path.h"
#include "read-cache-ll.h"
#include "replace-object.h"
Expand Down Expand Up @@ -340,7 +340,8 @@ static void check_unreachable_object(struct object *obj)
}
f = xfopen(filename, "w");
if (obj->type == OBJ_BLOB) {
if (stream_blob_to_fd(fileno(f), &obj->oid, NULL, 1))
if (odb_stream_blob_to_fd(the_repository->objects, fileno(f),
&obj->oid, NULL, 1))
die_errno(_("could not write '%s'"), filename);
} else
fprintf(f, "%s\n", describe_object(&obj->oid));
Expand Down
15 changes: 6 additions & 9 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#include "progress.h"
#include "fsck.h"
#include "strbuf.h"
#include "streaming.h"
#include "thread-utils.h"
#include "packfile.h"
#include "pack-revindex.h"
#include "object-file.h"
#include "odb.h"
#include "odb/streaming.h"
#include "oid-array.h"
#include "oidset.h"
#include "path.h"
Expand Down Expand Up @@ -762,7 +762,7 @@ static void find_ref_delta_children(const struct object_id *oid,

struct compare_data {
struct object_entry *entry;
struct git_istream *st;
struct odb_read_stream *st;
unsigned char *buf;
unsigned long buf_size;
};
Expand All @@ -779,7 +779,7 @@ static int compare_objects(const unsigned char *buf, unsigned long size,
}

while (size) {
ssize_t len = read_istream(data->st, data->buf, size);
ssize_t len = odb_read_stream_read(data->st, data->buf, size);
if (len == 0)
die(_("SHA1 COLLISION FOUND WITH %s !"),
oid_to_hex(&data->entry->idx.oid));
Expand All @@ -798,24 +798,21 @@ static int compare_objects(const unsigned char *buf, unsigned long size,
static int check_collison(struct object_entry *entry)
{
struct compare_data data;
enum object_type type;
unsigned long size;

if (entry->size <= repo_settings_get_big_file_threshold(the_repository) ||
entry->type != OBJ_BLOB)
return -1;

memset(&data, 0, sizeof(data));
data.entry = entry;
data.st = open_istream(the_repository, &entry->idx.oid, &type, &size,
NULL);
data.st = odb_read_stream_open(the_repository->objects, &entry->idx.oid, NULL);
if (!data.st)
return -1;
if (size != entry->size || type != entry->type)
if (data.st->size != entry->size || data.st->type != entry->type)
die(_("SHA1 COLLISION FOUND WITH %s !"),
oid_to_hex(&entry->idx.oid));
unpack_data(entry, compare_objects, &data);
close_istream(data.st);
odb_read_stream_close(data.st);
free(data.buf);
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "refs.h"
#include "object-name.h"
#include "odb.h"
#include "odb/streaming.h"
#include "pager.h"
#include "color.h"
#include "commit.h"
Expand All @@ -35,7 +36,6 @@
#include "parse-options.h"
#include "line-log.h"
#include "branch.h"
#include "streaming.h"
#include "version.h"
#include "mailmap.h"
#include "progress.h"
Expand Down Expand Up @@ -584,7 +584,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
fflush(rev->diffopt.file);
if (!rev->diffopt.flags.textconv_set_via_cmdline ||
!rev->diffopt.flags.allow_textconv)
return stream_blob_to_fd(1, oid, NULL, 0);
return odb_stream_blob_to_fd(the_repository->objects, 1, oid, NULL, 0);

if (get_oid_with_context(the_repository, obj_name,
GET_OID_RECORD_PATH,
Expand All @@ -594,7 +594,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
!textconv_object(the_repository, obj_context.path,
obj_context.mode, &oidc, 1, &buf, &size)) {
object_context_release(&obj_context);
return stream_blob_to_fd(1, oid, NULL, 0);
return odb_stream_blob_to_fd(the_repository->objects, 1, oid, NULL, 0);
}

if (!buf)
Expand Down
24 changes: 13 additions & 11 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "pack-objects.h"
#include "progress.h"
#include "refs.h"
#include "streaming.h"
#include "thread-utils.h"
#include "pack-bitmap.h"
#include "delta-islands.h"
Expand All @@ -33,6 +32,7 @@
#include "packfile.h"
#include "object-file.h"
#include "odb.h"
#include "odb/streaming.h"
#include "replace-object.h"
#include "dir.h"
#include "midx.h"
Expand Down Expand Up @@ -404,7 +404,7 @@ static unsigned long do_compress(void **pptr, unsigned long size)
return stream.total_out;
}

static unsigned long write_large_blob_data(struct git_istream *st, struct hashfile *f,
static unsigned long write_large_blob_data(struct odb_read_stream *st, struct hashfile *f,
const struct object_id *oid)
{
git_zstream stream;
Expand All @@ -417,7 +417,7 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct hashfi
for (;;) {
ssize_t readlen;
int zret = Z_OK;
readlen = read_istream(st, ibuf, sizeof(ibuf));
readlen = odb_read_stream_read(st, ibuf, sizeof(ibuf));
if (readlen == -1)
die(_("unable to read %s"), oid_to_hex(oid));

Expand Down Expand Up @@ -513,17 +513,19 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
unsigned hdrlen;
enum object_type type;
void *buf;
struct git_istream *st = NULL;
struct odb_read_stream *st = NULL;
const unsigned hashsz = the_hash_algo->rawsz;

if (!usable_delta) {
if (oe_type(entry) == OBJ_BLOB &&
oe_size_greater_than(&to_pack, entry,
repo_settings_get_big_file_threshold(the_repository)) &&
(st = open_istream(the_repository, &entry->idx.oid, &type,
&size, NULL)) != NULL)
(st = odb_read_stream_open(the_repository->objects, &entry->idx.oid,
NULL)) != NULL) {
buf = NULL;
else {
type = st->type;
size = st->size;
} else {
buf = odb_read_object(the_repository->objects,
&entry->idx.oid, &type,
&size);
Expand Down Expand Up @@ -577,7 +579,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
dheader[--pos] = 128 | (--ofs & 127);
if (limit && hdrlen + sizeof(dheader) - pos + datalen + hashsz >= limit) {
if (st)
close_istream(st);
odb_read_stream_close(st);
free(buf);
return 0;
}
Expand All @@ -591,7 +593,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
*/
if (limit && hdrlen + hashsz + datalen + hashsz >= limit) {
if (st)
close_istream(st);
odb_read_stream_close(st);
free(buf);
return 0;
}
Expand All @@ -601,15 +603,15 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
} else {
if (limit && hdrlen + datalen + hashsz >= limit) {
if (st)
close_istream(st);
odb_read_stream_close(st);
free(buf);
return 0;
}
hashwrite(f, header, hdrlen);
}
if (st) {
datalen = write_large_blob_data(st, f, &entry->idx.oid);
close_istream(st);
odb_read_stream_close(st);
} else {
hashwrite(f, buf, datalen);
free(buf);
Expand Down
Loading