ref-filter: get rid of show_ref_array_item

Inlining the exported function `show_ref_array_item()`,
which is not providing the right level of abstraction,
simplifies the API and can unlock improvements at the
former call sites.

Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
ZheNing Hu
2021-04-19 11:28:44 +00:00
committed by Junio C Hamano
parent b0c09ab879
commit 22f69a85ed
4 changed files with 34 additions and 21 deletions

View File

@ -63,8 +63,18 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting,
filter_refs(&array, filter, FILTER_REFS_TAGS);
ref_array_sort(sorting, &array);
for (i = 0; i < array.nr; i++)
show_ref_array_item(array.items[i], format);
for (i = 0; i < array.nr; i++) {
struct strbuf output = STRBUF_INIT;
struct strbuf err = STRBUF_INIT;
if (format_ref_array_item(array.items[i], format, &output, &err))
die("%s", err.buf);
fwrite(output.buf, 1, output.len, stdout);
putchar('\n');
strbuf_release(&err);
strbuf_release(&output);
}
ref_array_clear(&array);
free(to_free);