Re: [PATCH 09/13] upload-pack: pass upload_pack_data to send_ref()
- From
Jeff King <peff@peff.net>
- Date
- May 15, 2020, 18:33 UTC
- Message-ID
- <20200515183356.GI3692649@coredump.intra.peff.net>
- In-Reply-To
- <20200515100454.14486-10-chriscool@tuxfamily.org>
On Fri, May 15, 2020 at 12:04:50PM +0200, Christian Couder wrote:
> As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' > more thoroughly, let's pass that struct to send_ref(), so that > this function, and the functions it calls, can use all the > fields of the struct in followup commits.
OK, this is the natural consequence of the previous patch. We could make use of data->writer, as below, but I don't think it buys us much.
I went looking for other things we could use from upload_pack_data, too. It looks like some bits like stateless_rpc could be re-used.
-Peff
diff --git a/upload-pack.c b/upload-pack.c index bc259f1713..7be81c479c 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1068,7 +1068,8 @@ static int send_ref(const char *refname, const struct object_id *oid, struct strbuf symref_info = STRBUF_INIT; format_symref_info(&symref_info, &data->symref); - packet_write_fmt(1, "%s %s%c%s%s%s%s%s%s agent=%s\n", + packet_writer_write(&data->writer, + "%s %s%c%s%s%s%s%s%s agent=%s\n", oid_to_hex(oid), refname_nons, 0, capabilities, (allow_unadvertised_object_request & ALLOW_TIP_SHA1) ? @@ -1081,11 +1082,13 @@ static int send_ref(const char *refname, const struct object_id *oid, git_user_agent_sanitized()); strbuf_release(&symref_info); } else { - packet_write_fmt(1, "%s %s\n", oid_to_hex(oid), refname_nons); + packet_writer_write(&data->writer, "%s %s\n", + oid_to_hex(oid), refname_nons); } capabilities = NULL; if (!peel_ref(refname, &peeled)) - packet_write_fmt(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons); + packet_writer_write(&data->writer, "%s %s^{}\n", + oid_to_hex(&peeled), refname_nons); return 0; }