On Fri, Jun 25, 2021 at 9:32 PM ZheNing Hu via GitGitGadget <gitgitgadget@xxxxxxxxx> wrote: > > From: ZheNing Hu <adlternative@xxxxxxxxx> > > static void batch_object_write(const char *obj_name, > struct strbuf *scratch, > struct batch_options *opt, > struct expand_data *data) > { > - if (!data->skip_object_info && > - oid_object_info_extended(the_repository, &data->oid, &data->info, > - OBJECT_INFO_LOOKUP_REPLACE) < 0) { > - printf("%s missing\n", > - obj_name ? obj_name : oid_to_hex(&data->oid)); > - fflush(stdout); > - return; > - } > + int ret = 0; No need to initialize `ret` with 0. Later we are going to assign it with the return value of `format_ref_array_item()` anyway. > + struct strbuf err = STRBUF_INIT; > + struct ref_array_item item = { data->oid, data->rest }; > > strbuf_reset(scratch); > - strbuf_expand(scratch, opt->format, expand_format, data); > - strbuf_addch(scratch, '\n'); > - batch_write(opt, scratch->buf, scratch->len); > > - if (opt->print_contents) { > - print_object_or_die(opt, data); > - batch_write(opt, "\n", 1); > + ret = format_ref_array_item(&item, &opt->format, scratch, &err); Here. -- Hariom