From: Junio C Hamano Date: Mon, 30 Mar 2020 16:55:44 GMT Subject: Re: [PATCH 4/9] update-ref: organize commands in an array Message-ID: In-Reply-To: <20200330080551.GA186019@ncase.pks.im> Patrick Steinhardt 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.