Karthik Nayak <[email protected]> writes:
> On Wed, Aug 26, 2015 at 8:07 PM, Junio C Hamano <[email protected]> wrote:
>>
>> ... You can give a new format_ref_array_item()
>> that does not print but fills a strbuf to this caller, make
>> show_ref_array_item() a thin wrapper that calls it and prints it
>> with the final LF for other callers.
>>
> You're saying remove show_ref_array_item() (even the wrapper you mentioned
> above) and just have something like format_ref_array_item() which
> would output to a strbuf. and let the caller worry about the printing?
Among the current callers, the one in builtin/tag.c that wants to
trigger show_tag_lines() hack embedded in show_ref_array_item()
function can stop calling show_ref_array_item() and instead can do
for (i = 0; i < array.nr; i++) {
struct strbuf out = STRBUF_INIT;
format_ref_array_item(&out, ...);
if (filter->lines) {
... append tag lines to out ...
}
printf("%s\n", out.buf);
strbuf_reset(&out);
}
The current and future callers of show_ref_array_item() that do not
want to trigger the show_tag_liens() hack embedded in there may
still want it to print the formatted string including the trailing
LF, so you can keep show_ref_array_item() as a thin wrapper around
format_ref_array_item() for them to call, e.g.
show_ref_array_item(...) {
struct strbuf out = STRBUF_INIT;
format_ref_array_item(&out, ...);
printf("%s\n", out.buf);
strbuf_release(&out);
}
But if it has only one caller each, you may not even want to have
show_ref_array_item(), if you are going to do the "output to strbuf"
variant.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html