Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheNing Hu <adlternative@gmail.com>2021-04-19 14:28:44 +0300
committerJunio C Hamano <gitster@pobox.com>2021-04-20 01:08:00 +0300
commit22f69a85edf29dba2278b55f14419e4ea48148d2 (patch)
tree76728ec76cae6f9ebb063efa1b94c15579d04546 /ref-filter.c
parentb0c09ab8796fb736efa432b8e817334f3e5ee75a (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 'ref-filter.c')
-rw-r--r--ref-filter.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/ref-filter.c b/ref-filter.c
index a0adb4551d..e2eac50d95 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2435,27 +2435,22 @@ int format_ref_array_item(struct ref_array_item *info,
return 0;
}
-void show_ref_array_item(struct ref_array_item *info,
- const struct ref_format *format)
-{
- struct strbuf final_buf = STRBUF_INIT;
- struct strbuf error_buf = STRBUF_INIT;
-
- if (format_ref_array_item(info, format, &final_buf, &error_buf))
- die("%s", error_buf.buf);
- fwrite(final_buf.buf, 1, final_buf.len, stdout);
- strbuf_release(&error_buf);
- strbuf_release(&final_buf);
- putchar('\n');
-}
-
void pretty_print_ref(const char *name, const struct object_id *oid,
const struct ref_format *format)
{
struct ref_array_item *ref_item;
+ struct strbuf output = STRBUF_INIT;
+ struct strbuf err = STRBUF_INIT;
+
ref_item = new_ref_array_item(name, oid);
ref_item->kind = ref_kind_from_refname(name);
- show_ref_array_item(ref_item, format);
+ if (format_ref_array_item(ref_item, format, &output, &err))
+ die("%s", err.buf);
+ fwrite(output.buf, 1, output.len, stdout);
+ putchar('\n');
+
+ strbuf_release(&err);
+ strbuf_release(&output);
free_array_item(ref_item);
}