From: Junio C Hamano Date: Tue, 08 May 2018 03:50:35 GMT Subject: Re: [PATCH v6 05/13] git.c: convert --list-* to --list-cmds=* Message-ID: In-Reply-To: <20180507175222.12114-6-pclouds@gmail.com> Nguyễn Thái Ngọc Duy writes: > Even if these are hidden options, let's make them a bit more generic > since we're introducing more listing types shortly. The code is > structured to allow combining multiple listing types together because > we will soon add more types the 'builtins'. > > 'parseopt' remains separate because it has separate (SPC) to match > git-completion.bash needs and will not combine with others. > --- Missing sign-off. > +static int list_cmds(const char *spec) > +{ > + while (*spec) { > + const char *sep = strchrnul(spec, ','); > + int len = sep - spec; > + > + if (len == 8 && !strncmp(spec, "builtins", 8)) > + list_builtins(0, '\n'); This is the origin of ugliness we see in later steps that follow the same if (len == strlen(constS) && !strncmp(spec, constS, strlen(constS)) pattern added here. Could we have a small helper that takes len, spec, and constS to abstract "8" away?