* Common steps for the inner git_deflate() loop for writing loose * objects. Returns what git_deflate() returns. */
| 702 | * objects. Returns what git_deflate() returns. |
| 703 | */ |
| 704 | static int write_loose_object_common(struct odb_source_loose *loose, |
| 705 | struct git_hash_ctx *c, struct git_hash_ctx *compat_c, |
| 706 | git_zstream *stream, const int flush, |
| 707 | unsigned char *in0, const int fd, |
| 708 | unsigned char *compressed, |
| 709 | const size_t compressed_len) |
| 710 | { |
| 711 | const struct git_hash_algo *compat = loose->base.odb->repo->compat_hash_algo; |
| 712 | int ret; |
| 713 | |
| 714 | ret = git_deflate(stream, flush ? Z_FINISH : 0); |
| 715 | git_hash_update(c, in0, stream->next_in - in0); |
| 716 | if (compat && compat_c) |
| 717 | git_hash_update(compat_c, in0, stream->next_in - in0); |
| 718 | if (write_in_full(fd, compressed, stream->next_out - compressed) < 0) |
| 719 | die_errno(_("unable to write loose object file")); |
| 720 | stream->next_out = compressed; |
| 721 | stream->avail_out = compressed_len; |
| 722 | |
| 723 | return ret; |
| 724 | } |
| 725 | |
| 726 | /** |
| 727 | * Common steps for loose object writers to end writing loose objects: |
no test coverage detected