diff options
author | ZheNing Hu <adlternative@gmail.com> | 2021-04-19 14:28:44 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-04-20 01:08:00 +0300 |
commit | 22f69a85edf29dba2278b55f14419e4ea48148d2 (patch) | |
tree | 76728ec76cae6f9ebb063efa1b94c15579d04546 /builtin/for-each-ref.c | |
parent | b0c09ab8796fb736efa432b8e817334f3e5ee75a (diff) |
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>
Diffstat (limited to 'builtin/for-each-ref.c')
-rw-r--r-- | builtin/for-each-ref.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index cb9c81a046..8520008604 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -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; } |