Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 16, 2018, 06:28 UTC
- Message-ID
- <xmqq36zvy8a5.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180415164238.9107-4-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 5 quoted lines
> @@ -23,28 +36,44 @@ sed -n ' > ' "$1" > printf '};\n\n' > > +echo "#define GROUP_NONE 0xff /* no common group */"
Some later code forgets about this value, and causes "git<ENTER>" to segfault at the end of this entire series.
Namely, here:
Show 5 quoted lines
> - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> + for (i = 0; i < nr; i++) {
> if (common_cmds[i].group != current_grp) {
> printf("\n%s\n", _(common_cmd_groups[common_cmds[i].group]));
> current_grp = common_cmds[i].group;where common_cmd_groups[] gets overrun.
Here is a squash I'll queue on top to keep the tip of 'pu' at least buildable.
help.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/help.c b/help.c index a44f4a113e..74591d5ebc 100644 --- a/help.c +++ b/help.c @@ -242,7 +242,9 @@ void list_common_cmds_help(void) puts(_("These are common Git commands used in various situations:")); for (i = 0; i < nr; i++) { - if (common_cmds[i].group != current_grp) { + if (ARRAY_SIZE(common_cmd_groups) <= common_cmds[i].group) + ; /* skip */ + else if (common_cmds[i].group != current_grp) { printf("\n%s\n", _(common_cmd_groups[common_cmds[i].group])); current_grp = common_cmds[i].group; }