mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
streaming: convert open_istream to use struct object_id
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
17e65451e3
commit
ef7b5195f1
@ -119,7 +119,7 @@ static int stream_blocked(const struct object_id *oid)
|
|||||||
char buf[BLOCKSIZE];
|
char buf[BLOCKSIZE];
|
||||||
ssize_t readlen;
|
ssize_t readlen;
|
||||||
|
|
||||||
st = open_istream(oid->hash, &type, &sz, NULL);
|
st = open_istream(oid, &type, &sz, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
return error("cannot stream blob %s", oid_to_hex(oid));
|
return error("cannot stream blob %s", oid_to_hex(oid));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -337,7 +337,7 @@ static int write_zip_entry(struct archiver_args *args,
|
|||||||
|
|
||||||
if (S_ISREG(mode) && type == OBJ_BLOB && !args->convert &&
|
if (S_ISREG(mode) && type == OBJ_BLOB && !args->convert &&
|
||||||
size > big_file_threshold) {
|
size > big_file_threshold) {
|
||||||
stream = open_istream(oid->hash, &type, &size, NULL);
|
stream = open_istream(oid, &type, &size, NULL);
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return error("cannot stream blob %s",
|
return error("cannot stream blob %s",
|
||||||
oid_to_hex(oid));
|
oid_to_hex(oid));
|
||||||
|
@ -771,7 +771,7 @@ static int check_collison(struct object_entry *entry)
|
|||||||
|
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
data.entry = entry;
|
data.entry = entry;
|
||||||
data.st = open_istream(entry->idx.oid.hash, &type, &size, NULL);
|
data.st = open_istream(&entry->idx.oid, &type, &size, NULL);
|
||||||
if (!data.st)
|
if (!data.st)
|
||||||
return -1;
|
return -1;
|
||||||
if (size != entry->size || type != entry->type)
|
if (size != entry->size || type != entry->type)
|
||||||
|
@ -267,7 +267,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
|
|||||||
if (!usable_delta) {
|
if (!usable_delta) {
|
||||||
if (entry->type == OBJ_BLOB &&
|
if (entry->type == OBJ_BLOB &&
|
||||||
entry->size > big_file_threshold &&
|
entry->size > big_file_threshold &&
|
||||||
(st = open_istream(entry->idx.oid.hash, &type, &size, NULL)) != NULL)
|
(st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL)
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
else {
|
else {
|
||||||
buf = read_sha1_file(entry->idx.oid.hash, &type,
|
buf = read_sha1_file(entry->idx.oid.hash, &type,
|
||||||
|
@ -799,7 +799,7 @@ int check_object_signature(const struct object_id *oid, void *map,
|
|||||||
return oidcmp(oid, &real_oid) ? -1 : 0;
|
return oidcmp(oid, &real_oid) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
st = open_istream(oid->hash, &obj_type, &size, NULL);
|
st = open_istream(oid, &obj_type, &size, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -130,14 +130,14 @@ static enum input_source istream_source(const unsigned char *sha1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct git_istream *open_istream(const unsigned char *sha1,
|
struct git_istream *open_istream(const struct object_id *oid,
|
||||||
enum object_type *type,
|
enum object_type *type,
|
||||||
unsigned long *size,
|
unsigned long *size,
|
||||||
struct stream_filter *filter)
|
struct stream_filter *filter)
|
||||||
{
|
{
|
||||||
struct git_istream *st;
|
struct git_istream *st;
|
||||||
struct object_info oi = OBJECT_INFO_INIT;
|
struct object_info oi = OBJECT_INFO_INIT;
|
||||||
const unsigned char *real = lookup_replace_object(sha1);
|
const unsigned char *real = lookup_replace_object(oid->hash);
|
||||||
enum input_source src = istream_source(real, type, &oi);
|
enum input_source src = istream_source(real, type, &oi);
|
||||||
|
|
||||||
if (src < 0)
|
if (src < 0)
|
||||||
@ -507,7 +507,7 @@ int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter
|
|||||||
ssize_t kept = 0;
|
ssize_t kept = 0;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
st = open_istream(oid->hash, &type, &sz, filter);
|
st = open_istream(oid, &type, &sz, filter);
|
||||||
if (!st) {
|
if (!st) {
|
||||||
if (filter)
|
if (filter)
|
||||||
free_stream_filter(filter);
|
free_stream_filter(filter);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
/* opaque */
|
/* opaque */
|
||||||
struct git_istream;
|
struct git_istream;
|
||||||
|
|
||||||
extern struct git_istream *open_istream(const unsigned char *, enum object_type *, unsigned long *, struct stream_filter *);
|
extern struct git_istream *open_istream(const struct object_id *, enum object_type *, unsigned long *, struct stream_filter *);
|
||||||
extern int close_istream(struct git_istream *);
|
extern int close_istream(struct git_istream *);
|
||||||
extern ssize_t read_istream(struct git_istream *, void *, size_t);
|
extern ssize_t read_istream(struct git_istream *, void *, size_t);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user