Skip to content

Commit 3f55cf0

Browse files
dschoGit for Windows Build Agent
authored andcommitted
fixup??? git: catch an attempt to run "git-foo"
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]>
1 parent e3a89bd commit 3f55cf0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

git.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ int cmd_main(int argc, const char **argv)
870870
* that one cannot handle it.
871871
*/
872872
if (skip_prefix(cmd, "git-", &cmd)) {
873-
warn_on_dashed_git(argv[0]);
873+
strip_extension(&cmd);
874+
warn_on_dashed_git(cmd);
874875

875876
argv[0] = cmd;
876877
handle_builtin(argc, argv);

help.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,12 @@ NORETURN void help_unknown_ref(const char *ref, const char *cmd,
726726
static struct cmdname_help *find_cmdname_help(const char *name)
727727
{
728728
int i;
729+
const char *p;
729730

731+
skip_prefix(name, "git-", &name);
730732
for (i = 0; i < ARRAY_SIZE(command_list); i++) {
731-
if (!strcmp(command_list[i].name, name))
733+
if (skip_prefix(command_list[i].name, "git-", &p) &&
734+
!strcmp(p, name))
732735
return &command_list[i];
733736
}
734737
return NULL;

0 commit comments

Comments
 (0)