Re: [PATCH v6 05/13] pkt-line: add packet_write_gently()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 26, 2016, 17:15 UTC
- Message-ID
- <xmqqeg5bih8h.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <0BD3A97F-A9FD-45A6-AF82-E01CC6B9BA89@gmail.com>
Lars Schneider <larsxschneider@gmail.com> writes:
Show 12 quoted lines
>> Do you anticipate future need of non-gently variant of this >> function? If so, perhaps a helper that takes a boolean "am I >> working for the gently variant?" may help share more code. > > With helper you mean "an additional boolean parameter"? I don't > see a need for a non-gently variant right now but I will > add this parameter if you think it is a good idea. How would the > signature look like? > > int packet_write_gently(const int fd_out, const char *buf, size_t size, int gentle) > > This would follow type_from_string_gently() in object.h.
I actually imagined it would be more like your packet_write_fmt vs packet_write_fmt_gently pair of functions. If you do not have an immediate need for a non-gentle packet_write() right now, but you still forsee that it is likely some other caller may want one, you could still prepare for it by doing a static
packet_write_1((const int fd_out, const char *buf, size_t size, int gentle)
and make packet_write_gently() call it with gentle=1, without actually introducing packet_write() nobody yet calls.