X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=sha1_file.c;h=5ec5598d7d6cd56ebb40b21c497c0ae3db1dca57;hb=429a9358763dfb98cd063e40dc49cbc049e2a268;hp=15fd6e04360c2a963766d940b73775002abb0b77;hpb=d5f1befca880ee64230d876535f0f98c5ea6bb86;p=git.git diff --git a/sha1_file.c b/sha1_file.c index 15fd6e04..5ec5598d 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1035,14 +1035,17 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size { unsigned long mapsize; void *map, *buf; + struct pack_entry e; + if (find_pack_entry(sha1, &e)) + return read_packed_sha1(sha1, type, size); map = map_sha1_file_internal(sha1, &mapsize); if (map) { buf = unpack_sha1_file(map, mapsize, type, size); munmap(map, mapsize); return buf; } - return read_packed_sha1(sha1, type, size); + return NULL; } void *read_object_with_reference(const unsigned char *sha1, @@ -1216,7 +1219,7 @@ int write_sha1_to_fd(int fd, const unsigned char *sha1) ssize_t size; unsigned long objsize; int posn = 0; - char *buf = map_sha1_file_internal(sha1, &objsize); + void *buf = map_sha1_file_internal(sha1, &objsize); z_stream stream; if (!buf) { unsigned char *unpacked; @@ -1240,7 +1243,7 @@ int write_sha1_to_fd(int fd, const unsigned char *sha1) stream.avail_out = size; /* First header.. */ - stream.next_in = hdr; + stream.next_in = (void *)hdr; stream.avail_in = hdrlen; while (deflate(&stream, 0) == Z_OK) /* nothing */; @@ -1343,9 +1346,9 @@ int has_sha1_file(const unsigned char *sha1) struct stat st; struct pack_entry e; - if (find_sha1_file(sha1, &st)) + if (find_pack_entry(sha1, &e)) return 1; - return find_pack_entry(sha1, &e); + return find_sha1_file(sha1, &st) ? 1 : 0; } int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, const char *type)