diff options
| author | ZheNing Hu <adlternative@gmail.com> | 2021-04-19 11:28:44 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-04-19 15:08:00 -0700 |
| commit | 22f69a85edf29dba2278b55f14419e4ea48148d2 (patch) | |
| tree | 76728ec76cae6f9ebb063efa1b94c15579d04546 /builtin | |
| parent | b0c09ab8796fb736efa432b8e817334f3e5ee75a (diff) | |
| download | git-22f69a85edf29dba2278b55f14419e4ea48148d2.tar.xz | |
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')
| -rw-r--r-- | builtin/for-each-ref.c | 14 | ||||
| -rw-r--r-- | builtin/tag.c | 14 |
2 files changed, 24 insertions, 4 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; } diff --git a/builtin/tag.c b/builtin/tag.c index d403417b56..d92d8e110b 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -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); |
