Re: [PATCH v11 8/8] cat-file: add remote-object-info to batch-command
On Mon, Feb 24, 2025 at 6:47 PM Jeff King <peff@peff.net> wrote:
Show 24 quoted lines
>
> On Fri, Feb 21, 2025 at 02:04:49PM -0500, Eric Ju wrote:
>
> > +static int get_remote_info(struct batch_options *opt, int argc, const char **argv)
> > [...]
> > + if (gtransport->smart_options) {
> > + CALLOC_ARRAY(remote_object_info, object_info_oids.nr);
> > + gtransport->smart_options->object_info = 1;
> > + gtransport->smart_options->object_info_oids = &object_info_oids;
> > +
> > + /* 'objectsize' is the only option currently supported */
> > + if (!strstr(opt->format, "%(objectsize)"))
> > + die(_("%s is currently not supported with remote-object-info"), opt->format);
>
> BTW, this strstr() isn't quite sufficient to prevent problems, as it
> would not find placeholders which _do_ exist but which aren't handled.
> One of the first things I tried was:
>
> git cat-file --batch-command='%(objecttype) %(objectsize)'
>
> and feeding it "remote-object-info /path/to/repo some-oid". And it
> segfaulted.
>
> -PeffThank you, Peff. Yes, you are right. It is a bug. I am adding a new
logic in v12:
1. Iterating on the `opt->format` to see if there are any unsupported
placeholders. If there is, error with unspported placeholders.
2. Adding more test cases to cover different formats, e.g., just
`%(objectsize)`, just `%(objectname)`, mixed usage of supported and
unsupported placeholders.