The existing `stream_blob_to_pack()` function is named based on the fact that it knows only how to stream blobs into a bulk-checkin pack. But there is no longer anything in this function which prevents us from writing objects of arbitrary types to the bulk-checkin pack. Prepare to write OBJ_TREEs by removing this assumption, adding an `enum object_type` parameter to this function's argument list, and renaming it to `stream_obj_to_pack()` accordingly. Signed-off-by: Taylor Blau <me@xxxxxxxxxxxx> --- bulk-checkin.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bulk-checkin.c b/bulk-checkin.c index c05d06e1e1..7e6b52112e 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -188,10 +188,10 @@ static ssize_t bulk_checkin_source_read(struct bulk_checkin_source *source, * status before calling us just in case we ask it to call us again * with a new pack. */ -static int stream_blob_to_pack(struct bulk_checkin_packfile *state, - git_hash_ctx *ctx, off_t *already_hashed_to, - struct bulk_checkin_source *source, - unsigned flags) +static int stream_obj_to_pack(struct bulk_checkin_packfile *state, + git_hash_ctx *ctx, off_t *already_hashed_to, + struct bulk_checkin_source *source, + enum object_type type, unsigned flags) { git_zstream s; unsigned char ibuf[16384]; @@ -204,8 +204,7 @@ static int stream_blob_to_pack(struct bulk_checkin_packfile *state, git_deflate_init(&s, pack_compression_level); - hdrlen = encode_in_pack_object_header(obuf, sizeof(obuf), OBJ_BLOB, - size); + hdrlen = encode_in_pack_object_header(obuf, sizeof(obuf), type, size); s.next_out = obuf + hdrlen; s.avail_out = sizeof(obuf) - hdrlen; @@ -327,8 +326,8 @@ static int deflate_blob_to_pack(struct bulk_checkin_packfile *state, idx->offset = state->offset; crc32_begin(state->f); } - if (!stream_blob_to_pack(state, &ctx, &already_hashed_to, - &source, flags)) + if (!stream_obj_to_pack(state, &ctx, &already_hashed_to, + &source, OBJ_BLOB, flags)) break; /* * Writing this object to the current pack will make -- 2.42.0.405.g86fe3250c2