Skip to content

Commit

Permalink
fixup??? git: catch an attempt to run "git-foo"
Browse files Browse the repository at this point in the history
This is needed to handle the case where `argv[0]` contains the full path
(which is the case on Windows) and the suffix `.exe` (which is also the
case on Windows).

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Oct 8, 2020
1 parent d2b901c commit a41f7cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,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);

argv[0] = cmd;
handle_builtin(argc, argv);
Expand Down
5 changes: 4 additions & 1 deletion help.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,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;
Expand Down

0 comments on commit a41f7cb

Please sign in to comment.