odb/streaming: rename `struct odb_read_stream`
Rename `struct odb_read_stream` to just `struct odb_stream`. This prepares for unification of the two different types of streams, as these provide the same functionality with the preceding refactorings. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>main
parent
8a51f6e8c5
commit
a59e4798f0
|
|
@ -129,7 +129,7 @@ static void write_trailer(void)
|
|||
*/
|
||||
static int stream_blocked(struct repository *r, const struct object_id *oid)
|
||||
{
|
||||
struct odb_read_stream *st;
|
||||
struct odb_stream *st;
|
||||
char buf[BLOCKSIZE];
|
||||
ssize_t readlen;
|
||||
|
||||
|
|
@ -137,12 +137,12 @@ static int stream_blocked(struct repository *r, const struct object_id *oid)
|
|||
if (!st)
|
||||
return error(_("cannot stream blob %s"), oid_to_hex(oid));
|
||||
for (;;) {
|
||||
readlen = odb_read_stream_read(st, buf, sizeof(buf));
|
||||
readlen = odb_stream_read(st, buf, sizeof(buf));
|
||||
if (readlen <= 0)
|
||||
break;
|
||||
do_write_blocked(buf, readlen);
|
||||
}
|
||||
odb_read_stream_close(st);
|
||||
odb_stream_close(st);
|
||||
if (!readlen)
|
||||
finish_record();
|
||||
return readlen;
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ static int write_zip_entry(struct archiver_args *args,
|
|||
enum zip_method method;
|
||||
unsigned char *out;
|
||||
void *deflated = NULL;
|
||||
struct odb_read_stream *stream = NULL;
|
||||
struct odb_stream *stream = NULL;
|
||||
unsigned long flags = 0;
|
||||
int is_binary = -1;
|
||||
const char *path_without_prefix = path + args->baselen;
|
||||
|
|
@ -428,7 +428,7 @@ static int write_zip_entry(struct archiver_args *args,
|
|||
ssize_t readlen;
|
||||
|
||||
for (;;) {
|
||||
readlen = odb_read_stream_read(stream, buf, sizeof(buf));
|
||||
readlen = odb_stream_read(stream, buf, sizeof(buf));
|
||||
if (readlen <= 0)
|
||||
break;
|
||||
crc = crc32(crc, buf, readlen);
|
||||
|
|
@ -438,7 +438,7 @@ static int write_zip_entry(struct archiver_args *args,
|
|||
buf, readlen);
|
||||
write_or_die(1, buf, readlen);
|
||||
}
|
||||
odb_read_stream_close(stream);
|
||||
odb_stream_close(stream);
|
||||
if (readlen)
|
||||
return readlen;
|
||||
|
||||
|
|
@ -461,7 +461,7 @@ static int write_zip_entry(struct archiver_args *args,
|
|||
zstream.avail_out = sizeof(compressed);
|
||||
|
||||
for (;;) {
|
||||
readlen = odb_read_stream_read(stream, buf, sizeof(buf));
|
||||
readlen = odb_stream_read(stream, buf, sizeof(buf));
|
||||
if (readlen <= 0)
|
||||
break;
|
||||
crc = crc32(crc, buf, readlen);
|
||||
|
|
@ -485,7 +485,7 @@ static int write_zip_entry(struct archiver_args *args,
|
|||
}
|
||||
|
||||
}
|
||||
odb_read_stream_close(stream);
|
||||
odb_stream_close(stream);
|
||||
if (readlen)
|
||||
return readlen;
|
||||
|
||||
|
|
|
|||
|
|
@ -763,7 +763,7 @@ static void find_ref_delta_children(const struct object_id *oid,
|
|||
|
||||
struct compare_data {
|
||||
struct object_entry *entry;
|
||||
struct odb_read_stream *st;
|
||||
struct odb_stream *st;
|
||||
unsigned char *buf;
|
||||
unsigned long buf_size;
|
||||
};
|
||||
|
|
@ -780,7 +780,7 @@ static int compare_objects(const unsigned char *buf, unsigned long size,
|
|||
}
|
||||
|
||||
while (size) {
|
||||
ssize_t len = odb_read_stream_read(data->st, data->buf, size);
|
||||
ssize_t len = odb_stream_read(data->st, data->buf, size);
|
||||
if (len == 0)
|
||||
die(_("SHA1 COLLISION FOUND WITH %s !"),
|
||||
oid_to_hex(&data->entry->idx.oid));
|
||||
|
|
@ -813,7 +813,7 @@ static int check_collison(struct object_entry *entry)
|
|||
die(_("SHA1 COLLISION FOUND WITH %s !"),
|
||||
oid_to_hex(&entry->idx.oid));
|
||||
unpack_data(entry, compare_objects, &data);
|
||||
odb_read_stream_close(data.st);
|
||||
odb_stream_close(data.st);
|
||||
free(data.buf);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ static unsigned long do_compress(void **pptr, unsigned long size)
|
|||
return stream.total_out;
|
||||
}
|
||||
|
||||
static unsigned long write_large_blob_data(struct odb_read_stream *st, struct hashfile *f,
|
||||
static unsigned long write_large_blob_data(struct odb_stream *st, struct hashfile *f,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
git_zstream stream;
|
||||
|
|
@ -425,7 +425,7 @@ static unsigned long write_large_blob_data(struct odb_read_stream *st, struct ha
|
|||
for (;;) {
|
||||
ssize_t readlen;
|
||||
int zret = Z_OK;
|
||||
readlen = odb_read_stream_read(st, ibuf, sizeof(ibuf));
|
||||
readlen = odb_stream_read(st, ibuf, sizeof(ibuf));
|
||||
if (readlen == -1)
|
||||
die(_("unable to read %s"), oid_to_hex(oid));
|
||||
|
||||
|
|
@ -521,7 +521,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
|
|||
unsigned hdrlen;
|
||||
enum object_type type;
|
||||
void *buf;
|
||||
struct odb_read_stream *st = NULL;
|
||||
struct odb_stream *st = NULL;
|
||||
const unsigned hashsz = the_hash_algo->rawsz;
|
||||
|
||||
if (!usable_delta) {
|
||||
|
|
@ -589,7 +589,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)
|
||||
odb_read_stream_close(st);
|
||||
odb_stream_close(st);
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -603,7 +603,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
|
|||
*/
|
||||
if (limit && hdrlen + hashsz + datalen + hashsz >= limit) {
|
||||
if (st)
|
||||
odb_read_stream_close(st);
|
||||
odb_stream_close(st);
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -613,7 +613,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
|
|||
} else {
|
||||
if (limit && hdrlen + datalen + hashsz >= limit) {
|
||||
if (st)
|
||||
odb_read_stream_close(st);
|
||||
odb_stream_close(st);
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -621,7 +621,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
|
|||
}
|
||||
if (st) {
|
||||
datalen = write_large_blob_data(st, f, &entry->idx.oid);
|
||||
odb_read_stream_close(st);
|
||||
odb_stream_close(st);
|
||||
} else {
|
||||
hashwrite(f, buf, datalen);
|
||||
free(buf);
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ int check_object_signature(struct repository *r, const struct object_id *oid,
|
|||
}
|
||||
|
||||
int stream_object_signature(struct repository *r,
|
||||
struct odb_read_stream *st,
|
||||
struct odb_stream *st,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
struct object_id real_oid;
|
||||
|
|
@ -138,7 +138,7 @@ int stream_object_signature(struct repository *r,
|
|||
git_hash_update(&c, hdr, hdrlen);
|
||||
for (;;) {
|
||||
char buf[1024 * 16];
|
||||
ssize_t readlen = odb_read_stream_read(st, buf, sizeof(buf));
|
||||
ssize_t readlen = odb_stream_read(st, buf, sizeof(buf));
|
||||
if (readlen < 0)
|
||||
return -1;
|
||||
if (!readlen)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ int check_object_signature(struct repository *r, const struct object_id *oid,
|
|||
* the streaming interface and rehash it to do the same.
|
||||
*/
|
||||
int stream_object_signature(struct repository *r,
|
||||
struct odb_read_stream *stream,
|
||||
struct odb_stream *stream,
|
||||
const struct object_id *oid);
|
||||
|
||||
enum finalize_object_file_flags {
|
||||
|
|
|
|||
6
object.c
6
object.c
|
|
@ -345,7 +345,7 @@ struct object *parse_object_with_flags(struct repository *r,
|
|||
if ((!obj || obj->type == OBJ_NONE || obj->type == OBJ_BLOB) &&
|
||||
odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) {
|
||||
if (!skip_hash) {
|
||||
struct odb_read_stream *stream = odb_read_stream_open(r->objects, oid, NULL);
|
||||
struct odb_stream *stream = odb_read_stream_open(r->objects, oid, NULL);
|
||||
|
||||
if (!stream) {
|
||||
error(_("unable to open object stream for %s"), oid_to_hex(oid));
|
||||
|
|
@ -354,11 +354,11 @@ struct object *parse_object_with_flags(struct repository *r,
|
|||
|
||||
if (stream_object_signature(r, stream, repl) < 0) {
|
||||
error(_("hash mismatch %s"), oid_to_hex(oid));
|
||||
odb_read_stream_close(stream);
|
||||
odb_stream_close(stream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
odb_read_stream_close(stream);
|
||||
odb_stream_close(stream);
|
||||
}
|
||||
parse_blob_buffer(lookup_blob(r, oid));
|
||||
return lookup_object(r, oid);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ static int odb_source_files_read_object_info(struct odb_source *source,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int odb_source_files_read_object_stream(struct odb_read_stream **out,
|
||||
static int odb_source_files_read_object_stream(struct odb_stream **out,
|
||||
struct odb_source *source,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -73,12 +73,12 @@ static int odb_source_inmemory_read_object_info(struct odb_source *source,
|
|||
}
|
||||
|
||||
struct odb_read_stream_inmemory {
|
||||
struct odb_read_stream base;
|
||||
struct odb_stream base;
|
||||
const unsigned char *buf;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
static ssize_t odb_read_stream_inmemory_read(struct odb_read_stream *stream,
|
||||
static ssize_t odb_read_stream_inmemory_read(struct odb_stream *stream,
|
||||
char *buf, size_t buf_len)
|
||||
{
|
||||
struct odb_read_stream_inmemory *inmemory =
|
||||
|
|
@ -94,12 +94,12 @@ static ssize_t odb_read_stream_inmemory_read(struct odb_read_stream *stream,
|
|||
return bytes;
|
||||
}
|
||||
|
||||
static int odb_read_stream_inmemory_close(struct odb_read_stream *stream UNUSED)
|
||||
static int odb_read_stream_inmemory_close(struct odb_stream *stream UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int odb_source_inmemory_read_object_stream(struct odb_read_stream **out,
|
||||
static int odb_source_inmemory_read_object_stream(struct odb_stream **out,
|
||||
struct odb_source *source,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ out:
|
|||
}
|
||||
|
||||
struct odb_loose_read_stream {
|
||||
struct odb_read_stream base;
|
||||
struct odb_stream base;
|
||||
git_zstream z;
|
||||
enum {
|
||||
ODB_LOOSE_READ_STREAM_INUSE,
|
||||
|
|
@ -292,7 +292,7 @@ struct odb_loose_read_stream {
|
|||
int hdr_used;
|
||||
};
|
||||
|
||||
static ssize_t read_istream_loose(struct odb_read_stream *_st, char *buf, size_t sz)
|
||||
static ssize_t read_istream_loose(struct odb_stream *_st, char *buf, size_t sz)
|
||||
{
|
||||
struct odb_loose_read_stream *st =
|
||||
container_of(_st, struct odb_loose_read_stream, base);
|
||||
|
|
@ -339,7 +339,7 @@ static ssize_t read_istream_loose(struct odb_read_stream *_st, char *buf, size_t
|
|||
return total_read;
|
||||
}
|
||||
|
||||
static int close_istream_loose(struct odb_read_stream *_st)
|
||||
static int close_istream_loose(struct odb_stream *_st)
|
||||
{
|
||||
struct odb_loose_read_stream *st =
|
||||
container_of(_st, struct odb_loose_read_stream, base);
|
||||
|
|
@ -350,7 +350,7 @@ static int close_istream_loose(struct odb_read_stream *_st)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int odb_source_loose_read_object_stream(struct odb_read_stream **out,
|
||||
static int odb_source_loose_read_object_stream(struct odb_stream **out,
|
||||
struct odb_source *source,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ static int odb_source_packed_read_object_info(struct odb_source *source,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int odb_source_packed_read_object_stream(struct odb_read_stream **out,
|
||||
static int odb_source_packed_read_object_stream(struct odb_stream **out,
|
||||
struct odb_source *source,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ enum odb_source_type {
|
|||
};
|
||||
|
||||
struct object_id;
|
||||
struct odb_read_stream;
|
||||
struct odb_stream;
|
||||
struct strvec;
|
||||
|
||||
/*
|
||||
|
|
@ -125,7 +125,7 @@ struct odb_source {
|
|||
* The callback is expected to return a negative error code in case
|
||||
* creating the object stream has failed, 0 otherwise.
|
||||
*/
|
||||
int (*read_object_stream)(struct odb_read_stream **out,
|
||||
int (*read_object_stream)(struct odb_stream **out,
|
||||
struct odb_source *source,
|
||||
const struct object_id *oid);
|
||||
|
||||
|
|
@ -339,7 +339,7 @@ static inline int odb_source_read_object_info(struct odb_source *source,
|
|||
* Create a new read stream for the given object ID. Returns 0 on success, a
|
||||
* negative error code otherwise.
|
||||
*/
|
||||
static inline int odb_source_read_object_stream(struct odb_read_stream **out,
|
||||
static inline int odb_source_read_object_stream(struct odb_stream **out,
|
||||
struct odb_source *source,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
*****************************************************************/
|
||||
|
||||
struct odb_filtered_read_stream {
|
||||
struct odb_read_stream base;
|
||||
struct odb_read_stream *upstream;
|
||||
struct odb_stream base;
|
||||
struct odb_stream *upstream;
|
||||
struct stream_filter *filter;
|
||||
char ibuf[FILTER_BUFFER];
|
||||
char obuf[FILTER_BUFFER];
|
||||
|
|
@ -30,14 +30,14 @@ struct odb_filtered_read_stream {
|
|||
int input_finished;
|
||||
};
|
||||
|
||||
static int close_istream_filtered(struct odb_read_stream *_fs)
|
||||
static int close_istream_filtered(struct odb_stream *_fs)
|
||||
{
|
||||
struct odb_filtered_read_stream *fs = (struct odb_filtered_read_stream *)_fs;
|
||||
free_stream_filter(fs->filter);
|
||||
return odb_read_stream_close(fs->upstream);
|
||||
return odb_stream_close(fs->upstream);
|
||||
}
|
||||
|
||||
static ssize_t read_istream_filtered(struct odb_read_stream *_fs, char *buf,
|
||||
static ssize_t read_istream_filtered(struct odb_stream *_fs, char *buf,
|
||||
size_t sz)
|
||||
{
|
||||
struct odb_filtered_read_stream *fs = (struct odb_filtered_read_stream *)_fs;
|
||||
|
|
@ -86,7 +86,7 @@ static ssize_t read_istream_filtered(struct odb_read_stream *_fs, char *buf,
|
|||
|
||||
/* refill the input from the upstream */
|
||||
if (!fs->input_finished) {
|
||||
fs->i_end = odb_read_stream_read(fs->upstream, fs->ibuf, FILTER_BUFFER);
|
||||
fs->i_end = odb_stream_read(fs->upstream, fs->ibuf, FILTER_BUFFER);
|
||||
if (fs->i_end < 0)
|
||||
return -1;
|
||||
if (fs->i_end)
|
||||
|
|
@ -97,8 +97,8 @@ static ssize_t read_istream_filtered(struct odb_read_stream *_fs, char *buf,
|
|||
return filled;
|
||||
}
|
||||
|
||||
static struct odb_read_stream *attach_stream_filter(struct odb_read_stream *st,
|
||||
struct stream_filter *filter)
|
||||
static struct odb_stream *attach_stream_filter(struct odb_stream *st,
|
||||
struct stream_filter *filter)
|
||||
{
|
||||
struct odb_filtered_read_stream *fs;
|
||||
|
||||
|
|
@ -120,19 +120,19 @@ static struct odb_read_stream *attach_stream_filter(struct odb_read_stream *st,
|
|||
*****************************************************************/
|
||||
|
||||
struct odb_incore_read_stream {
|
||||
struct odb_read_stream base;
|
||||
struct odb_stream base;
|
||||
char *buf; /* from odb_read_object_info_extended() */
|
||||
unsigned long read_ptr;
|
||||
};
|
||||
|
||||
static int close_istream_incore(struct odb_read_stream *_st)
|
||||
static int close_istream_incore(struct odb_stream *_st)
|
||||
{
|
||||
struct odb_incore_read_stream *st = (struct odb_incore_read_stream *)_st;
|
||||
free(st->buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t read_istream_incore(struct odb_read_stream *_st, char *buf, size_t sz)
|
||||
static ssize_t read_istream_incore(struct odb_stream *_st, char *buf, size_t sz)
|
||||
{
|
||||
struct odb_incore_read_stream *st = (struct odb_incore_read_stream *)_st;
|
||||
size_t read_size = sz;
|
||||
|
|
@ -147,7 +147,7 @@ static ssize_t read_istream_incore(struct odb_read_stream *_st, char *buf, size_
|
|||
return read_size;
|
||||
}
|
||||
|
||||
static int open_istream_incore(struct odb_read_stream **out,
|
||||
static int open_istream_incore(struct odb_stream **out,
|
||||
struct object_database *odb,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
|
|
@ -178,7 +178,7 @@ static int open_istream_incore(struct odb_read_stream **out,
|
|||
* static helpers variables and functions for users of streaming interface
|
||||
*****************************************************************************/
|
||||
|
||||
static int istream_source(struct odb_read_stream **out,
|
||||
static int istream_source(struct odb_stream **out,
|
||||
struct object_database *odb,
|
||||
const struct object_id *oid)
|
||||
{
|
||||
|
|
@ -196,23 +196,23 @@ static int istream_source(struct odb_read_stream **out,
|
|||
* Users of streaming interface
|
||||
****************************************************************/
|
||||
|
||||
int odb_read_stream_close(struct odb_read_stream *st)
|
||||
int odb_stream_close(struct odb_stream *st)
|
||||
{
|
||||
int r = st->close(st);
|
||||
free(st);
|
||||
return r;
|
||||
}
|
||||
|
||||
ssize_t odb_read_stream_read(struct odb_read_stream *st, void *buf, size_t sz)
|
||||
ssize_t odb_stream_read(struct odb_stream *st, void *buf, size_t sz)
|
||||
{
|
||||
return st->read(st, buf, sz);
|
||||
}
|
||||
|
||||
struct odb_read_stream *odb_read_stream_open(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
struct stream_filter *filter)
|
||||
struct odb_stream *odb_read_stream_open(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
struct stream_filter *filter)
|
||||
{
|
||||
struct odb_read_stream *st;
|
||||
struct odb_stream *st;
|
||||
const struct object_id *real = lookup_replace_object(odb->repo, oid);
|
||||
int ret = istream_source(&st, odb, real);
|
||||
|
||||
|
|
@ -221,9 +221,9 @@ struct odb_read_stream *odb_read_stream_open(struct object_database *odb,
|
|||
|
||||
if (filter) {
|
||||
/* Add "&& !is_null_stream_filter(filter)" for performance */
|
||||
struct odb_read_stream *nst = attach_stream_filter(st, filter);
|
||||
struct odb_stream *nst = attach_stream_filter(st, filter);
|
||||
if (!nst) {
|
||||
odb_read_stream_close(st);
|
||||
odb_stream_close(st);
|
||||
return NULL;
|
||||
}
|
||||
st = nst;
|
||||
|
|
@ -248,7 +248,7 @@ int odb_stream_blob_to_fd(struct object_database *odb,
|
|||
struct stream_filter *filter,
|
||||
int can_seek)
|
||||
{
|
||||
struct odb_read_stream *st;
|
||||
struct odb_stream *st;
|
||||
ssize_t kept = 0;
|
||||
int result = -1;
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ int odb_stream_blob_to_fd(struct object_database *odb,
|
|||
for (;;) {
|
||||
char buf[1024 * 16];
|
||||
ssize_t wrote, holeto;
|
||||
ssize_t readlen = odb_read_stream_read(st, buf, sizeof(buf));
|
||||
ssize_t readlen = odb_stream_read(st, buf, sizeof(buf));
|
||||
|
||||
if (readlen < 0)
|
||||
goto close_and_exit;
|
||||
|
|
@ -294,7 +294,7 @@ int odb_stream_blob_to_fd(struct object_database *odb,
|
|||
result = 0;
|
||||
|
||||
close_and_exit:
|
||||
odb_read_stream_close(st);
|
||||
odb_stream_close(st);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@
|
|||
#include "odb.h"
|
||||
|
||||
struct object_database;
|
||||
struct odb_read_stream;
|
||||
struct odb_stream;
|
||||
struct stream_filter;
|
||||
|
||||
typedef int (*odb_read_stream_close_fn)(struct odb_read_stream *);
|
||||
typedef ssize_t (*odb_read_stream_read_fn)(struct odb_read_stream *, char *, size_t);
|
||||
typedef int (*odb_stream_close_fn)(struct odb_stream *);
|
||||
typedef ssize_t (*odb_stream_read_fn)(struct odb_stream *, char *, size_t);
|
||||
|
||||
/*
|
||||
* A stream that can be used to read an object from the object database without
|
||||
* loading all of it into memory.
|
||||
*/
|
||||
struct odb_read_stream {
|
||||
odb_read_stream_close_fn close;
|
||||
odb_read_stream_read_fn read;
|
||||
struct odb_stream {
|
||||
odb_stream_close_fn close;
|
||||
odb_stream_read_fn read;
|
||||
enum object_type type;
|
||||
size_t size; /* inflated size of full object */
|
||||
};
|
||||
|
|
@ -31,22 +31,22 @@ struct odb_read_stream {
|
|||
*
|
||||
* Returns the stream on success, a `NULL` pointer otherwise.
|
||||
*/
|
||||
struct odb_read_stream *odb_read_stream_open(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
struct stream_filter *filter);
|
||||
struct odb_stream *odb_read_stream_open(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
struct stream_filter *filter);
|
||||
|
||||
/*
|
||||
* Close the given read stream and release all resources associated with it.
|
||||
* Close the given object stream and release all resources associated with it.
|
||||
* Returns 0 on success, a negative error code otherwise.
|
||||
*/
|
||||
int odb_read_stream_close(struct odb_read_stream *stream);
|
||||
int odb_stream_close(struct odb_stream *stream);
|
||||
|
||||
/*
|
||||
* Read data from the stream into the buffer. Returns 0 on EOF and the number
|
||||
* of bytes read on success. Returns a negative error code in case reading from
|
||||
* the stream fails.
|
||||
*/
|
||||
ssize_t odb_read_stream_read(struct odb_read_stream *stream, void *buf, size_t len);
|
||||
ssize_t odb_stream_read(struct odb_stream *stream, void *buf, size_t len);
|
||||
|
||||
/*
|
||||
* A stream that provides an object to be written to the object database without
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ static int verify_packfile(struct repository *r,
|
|||
QSORT(entries, nr_objects, compare_entries);
|
||||
|
||||
for (i = 0; i < nr_objects; i++) {
|
||||
struct odb_read_stream *stream = NULL;
|
||||
struct odb_stream *stream = NULL;
|
||||
void *data;
|
||||
struct object_id oid;
|
||||
enum object_type type;
|
||||
|
|
@ -171,7 +171,7 @@ static int verify_packfile(struct repository *r,
|
|||
display_progress(progress, base_count + i);
|
||||
|
||||
if (stream)
|
||||
odb_read_stream_close(stream);
|
||||
odb_stream_close(stream);
|
||||
free(data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2115,7 +2115,7 @@ int parse_pack_header_option(const char *in, unsigned char *out, unsigned int *l
|
|||
}
|
||||
|
||||
struct odb_packed_read_stream {
|
||||
struct odb_read_stream base;
|
||||
struct odb_stream base;
|
||||
struct packed_git *pack;
|
||||
git_zstream z;
|
||||
enum {
|
||||
|
|
@ -2127,7 +2127,7 @@ struct odb_packed_read_stream {
|
|||
off_t pos;
|
||||
};
|
||||
|
||||
static ssize_t read_istream_pack_non_delta(struct odb_read_stream *_st, char *buf,
|
||||
static ssize_t read_istream_pack_non_delta(struct odb_stream *_st, char *buf,
|
||||
size_t sz)
|
||||
{
|
||||
struct odb_packed_read_stream *st = (struct odb_packed_read_stream *)_st;
|
||||
|
|
@ -2187,7 +2187,7 @@ static ssize_t read_istream_pack_non_delta(struct odb_read_stream *_st, char *bu
|
|||
return total_read;
|
||||
}
|
||||
|
||||
static int close_istream_pack_non_delta(struct odb_read_stream *_st)
|
||||
static int close_istream_pack_non_delta(struct odb_stream *_st)
|
||||
{
|
||||
struct odb_packed_read_stream *st = (struct odb_packed_read_stream *)_st;
|
||||
if (st->z_state == ODB_PACKED_READ_STREAM_INUSE)
|
||||
|
|
@ -2195,7 +2195,7 @@ static int close_istream_pack_non_delta(struct odb_read_stream *_st)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int packfile_read_object_stream(struct odb_read_stream **out,
|
||||
int packfile_read_object_stream(struct odb_stream **out,
|
||||
const struct object_id *oid,
|
||||
struct packed_git *pack,
|
||||
off_t offset)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
/* in odb.h */
|
||||
struct object_info;
|
||||
struct odb_read_stream;
|
||||
struct odb_stream;
|
||||
|
||||
struct packed_git {
|
||||
struct pack_window *windows;
|
||||
|
|
@ -306,7 +306,7 @@ off_t get_delta_base(struct packed_git *p, struct pack_window **w_curs,
|
|||
off_t *curpos, enum object_type type,
|
||||
off_t delta_obj_offset);
|
||||
|
||||
int packfile_read_object_stream(struct odb_read_stream **out,
|
||||
int packfile_read_object_stream(struct odb_stream **out,
|
||||
const struct object_id *oid,
|
||||
struct packed_git *pack,
|
||||
off_t offset);
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ void test_odb_inmemory__read_written_object(void)
|
|||
void test_odb_inmemory__read_stream_object(void)
|
||||
{
|
||||
struct odb_source_inmemory *source = odb_source_inmemory_new(odb);
|
||||
struct odb_read_stream *stream;
|
||||
struct odb_stream *stream;
|
||||
struct object_id written_oid;
|
||||
const char data[] = "foobar";
|
||||
char buf[3] = { 0 };
|
||||
|
|
@ -112,15 +112,15 @@ void test_odb_inmemory__read_stream_object(void)
|
|||
cl_assert_equal_i(stream->type, OBJ_BLOB);
|
||||
cl_assert_equal_u(stream->size, 6);
|
||||
|
||||
cl_assert_equal_i(odb_read_stream_read(stream, buf, 2), 2);
|
||||
cl_assert_equal_i(odb_stream_read(stream, buf, 2), 2);
|
||||
cl_assert_equal_s(buf, "fo");
|
||||
cl_assert_equal_i(odb_read_stream_read(stream, buf, 2), 2);
|
||||
cl_assert_equal_i(odb_stream_read(stream, buf, 2), 2);
|
||||
cl_assert_equal_s(buf, "ob");
|
||||
cl_assert_equal_i(odb_read_stream_read(stream, buf, 2), 2);
|
||||
cl_assert_equal_i(odb_stream_read(stream, buf, 2), 2);
|
||||
cl_assert_equal_s(buf, "ar");
|
||||
cl_assert_equal_i(odb_read_stream_read(stream, buf, 2), 0);
|
||||
cl_assert_equal_i(odb_stream_read(stream, buf, 2), 0);
|
||||
|
||||
odb_read_stream_close(stream);
|
||||
odb_stream_close(stream);
|
||||
odb_source_free(&source->base);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue