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:
committed by
Junio C Hamano
parent
b0c09ab879
commit
22f69a85ed
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user