Re: [PATCH v5 12/15] [GSOC] cat-file: reuse ref-filter logic
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- Jun 27, 2021, 11:34 UTC
- Message-ID
- <CAOLTT8Qq4sgR9DnCk=+ovHUEqNeSkg-07fOpJQu5povaZFXgiA@mail.gmail.com>
- In-Reply-To
- <CA+CkUQ9XR4TjEea0Z4pHBeOdQi7fuTLPtzi01JdTKSS38=4CMg@mail.gmail.com>
Hariom verma <hariom18599@gmail.com> 于2021年6月27日周日 上午2:08写道:
Show 24 quoted lines
>
> On Fri, Jun 25, 2021 at 9:32 PM ZheNing Hu via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> >
> > 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.
>I agree. It is worth noting that there are similar `int ret = 0` in ref-filter.c, they should be changed too.
Show 17 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-- ZheNing Hu