Before we can successfully parse a builtin command from the program name we must strip off unneeded parts, that is, the file extension. Additionally, we must take Windows style path names into account. Signed-off-by: Johannes Sixt <johannes.sixt@xxxxxxxxxx> --- Makefile | 1 + git.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index bc8a487..069939f 100644 --- a/Makefile +++ b/Makefile @@ -543,6 +543,7 @@ ifneq (,$(findstring MINGW,$(uname_S))) NO_PERL_MAKEMAKER = YesPlease NO_EXTRA_PROGRAMS = YesPlease COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat + COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\" COMPAT_OBJS += compat/mingw.o compat/fnmatch.o compat/regex.o EXTLIBS += -lws2_32 X = .exe diff --git a/git.c b/git.c index 0cb8688..32166a4 100644 --- a/git.c +++ b/git.c @@ -372,6 +372,15 @@ static void handle_internal_command(int argc, const char **argv) }; int i; +#ifdef STRIP_EXTENSION + i = strlen(argv[0]) - strlen(STRIP_EXTENSION); + if (i > 0 && !strcmp(argv[0] + i, STRIP_EXTENSION)) { + char *argv0 = strdup(argv[0]); + argv[0] = cmd = argv0; + argv0[i] = '\0'; + } +#endif + /* Turn "git cmd --help" into "git help cmd" */ if (argc > 1 && !strcmp(argv[1], "--help")) { argv[1] = argv[0]; @@ -398,6 +407,11 @@ int main(int argc, const char **argv) * name, and the dirname as the default exec_path * if we don't have anything better. */ +#ifdef __MINGW32__ + char *bslash = strrchr(cmd, '\\'); + if (!slash || (bslash && bslash > slash)) + slash = bslash; +#endif if (slash) { *slash++ = 0; cmd_path = cmd; -- 1.5.4.1.126.ge5a7d - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html