Re: [PATCH 4/9] update-ref: organize commands in an array
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Mar 30, 2020, 17:37 UTC
- Message-ID
- <20200330173718.GA4837@ncase.pks.im>
- In-Reply-To
- <xmqqwo7193zj.fsf@gitster.c.googlers.com>
On Mon, Mar 30, 2020 at 09:55:44AM -0700, Junio C Hamano wrote:
Show 27 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
>
> >> for (i = 0; i < ARRAY_SIZE(command); i++) {
> >> const char *eoc;
> >> if (!skip_prefix(next, commands[i].prefix, &eoc) ||
> >> *eoc != ' ')
> >> continue;
> >> cmd = &command[i];
> >> next = eoc;
> >> break;
> >> }
> >
> > The reason why I moved those `skip_prefix` calls into each of the
> > respective commands is that this patch series introduces calls that do
> > not accept a trailing space at all. Thus we cannot handle the space
> > generically here, as that would was soon as we introduce the set of new
> > commands.
>
> That's not a good excuse, though, is it? The command[] structure
> can say "this takes parameters" or even "this takes N parameters",
> and the field being zero (i.e. "does not take parameters" or "takes
> zero parameters") would mean you do not want a trailing SP, no?
>
> I also suspect that the "extra lines" thing we'd see in a later step
> is correlated with this, but we'll see.
>
> Thanks.You've got a point there. I'll convert this for the next version, thanks!
Patrick