]> git.ipfire.org Git - thirdparty/git.git/blobdiff - ref-filter.c
The sixteenth batch
[thirdparty/git.git] / ref-filter.c
index f0bd32f714168d03394a3313c1ac6af196d5202f..e2eac50d9508ee6ea26d433e735774d48850aa83 100644 (file)
@@ -1608,7 +1608,7 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
 
        if (oi->info.contentp) {
                *obj = parse_object_buffer(the_repository, &oi->oid, oi->type, oi->size, oi->content, &eaten);
-               if (!obj) {
+               if (!*obj) {
                        if (!eaten)
                                free(oi->content);
                        return strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),
@@ -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);
 }