Re: [PATCH v5 12/15] [GSOC] cat-file: reuse ref-filter logic
- From
Hariom verma <hariom18599@gmail.com>
- Date
- Jun 26, 2021, 18:08 UTC
- Message-ID
- <CA+CkUQ9XR4TjEea0Z4pHBeOdQi7fuTLPtzi01JdTKSS38=4CMg@mail.gmail.com>
- In-Reply-To
- <370101ba65f0989487360366f8b83144a6641a04.1624636945.git.gitgitgadget@gmail.com>
On Fri, Jun 25, 2021 at 9:32 PM ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 17 quoted lines
>
> From: ZheNing Hu <adlternative@gmail.com>
>
> 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.
Show 12 quoted lines
> + 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