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

@ -80,8 +80,18 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
if (!maxcount || array.nr < maxcount)
maxcount = array.nr;
for (i = 0; i < maxcount; i++)
show_ref_array_item(array.items[i], &format);
for (i = 0; i < maxcount; 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);
return 0;
}