Hi Junio, On Fri, 28 Aug 2020, Junio C Hamano wrote: > Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes: > > > Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> > > --- > > git.c | 3 ++- > > help.c | 5 ++++- > > 2 files changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/git.c b/git.c > > index 71ef4835b20e..863fd0c58a66 100644 > > --- a/git.c > > +++ b/git.c > > @@ -851,7 +851,8 @@ int cmd_main(int argc, const char **argv) > > * that one cannot handle it. > > */ > > if (skip_prefix(cmd, "git-", &cmd)) { > > - warn_on_dashed_git(argv[0]); > > + strip_extension(&cmd); > > + warn_on_dashed_git(cmd); > > The argv[0] may have been NULL from the beginning of cmd_main(), and > cmd would be "git-help" in such a case. We used to pass NULL to > warn_on_dashed_git() in such a case because "git-help" is not what the > user typed, but what we internally trigger, so we didn't want > warn_on_dashed_git() to do anything based on that internal string. True. The test suite passes with this, though, which means we haven't covered that case. > As there is no special casing of "help" in warn_on_dashed_git() > mechanism, it probably would start triggering a warning/die when > "git<ENTER>" is typed, no? > > + if (argv[0]) { > strip_extension(&cmd); > warn_on_dashed_git(cmd); > > may be the minimum fix, but I would strongly prefer to keep the > interface into warn_on_dashed_git() (eh, the most important is the > interface into find_cmdname_help() helper function, which is > designed to be reused by other parts of help.c) to take the full > command name, not without "git-" prefix. This is primarily because > the entirety of the help.c API is driven by full command names, > without removing "git-" prefix, and it has to, because the help.c > API needs to handle "gitk", from which you cannot remove any "git-" > prefix. > > Perhaps > > if (starts_with(cmd, "git-")) { > strip_extension(&cmd); > if (argv[0]) > warn_on_dashed_git(cmd); > argv[0] = cmd + 4; > handle_builtin(argc, argv); > die(...); Sure. > How does your handle_builtin() work, by the way? > > The original code (even before we added warn_on_dashed_git() in this > codepath) did not do any strip_extension(), so handle_builtin() can > take commands with ".exe" suffix, but now we are feeding the result > of strip_extension() to it, so it can deal with both? Yes, it can deal with both. It calls `strip_extension()`, which on Windows removes the `.exe` suffix, if found. > Sounds convenient and sloppy (not the handle_builtin's > implementation, but its callers that sometimes feeds the full > executable name, and feeds only the basename some other times) at > the same time. Right, it does not _require_ the extension. I do not necessarily agree that it is sloppy, but I do agree that it is convenient ;-) Ciao, Dscho > > argv[0] = cmd; > > handle_builtin(argc, argv); > > diff --git a/help.c b/help.c > > index c93a76944b00..27b1b26890be 100644 > > --- a/help.c > > +++ b/help.c > > @@ -724,9 +724,12 @@ NORETURN void help_unknown_ref(const char *ref, const char *cmd, > > static struct cmdname_help *find_cmdname_help(const char *name) > > { > > int i; > > + const char *p; > > > > + skip_prefix(name, "git-", &name); > > for (i = 0; i < ARRAY_SIZE(command_list); i++) { > > - if (!strcmp(command_list[i].name, name)) > > + if (skip_prefix(command_list[i].name, "git-", &p) && > > + !strcmp(p, name)) > > return &command_list[i]; > > } > > return NULL; > > -- > > 2.28.0.windows.1 >