diff --git a/Makefile b/Makefile index 874e529e58..20065b7a11 100644 --- a/Makefile +++ b/Makefile @@ -425,7 +425,8 @@ ifneq (,$(findstring MINGW,$(uname_S))) NO_STRCASESTR=YesPlease NO_STRLCPY=YesPlease NO_ICONV=YesPlease - COMPAT_CFLAGS += -DNO_ETC_PASSWD -DNO_ST_BLOCKS -I compat + NO_SVN_TESTS=YesPlease + COMPAT_CFLAGS += -DNO_ETC_PASSWD -DNO_ST_BLOCKS -DSTRIP_EXTENSION=\".exe\" -I compat COMPAT_OBJS += compat/mingw.o compat/fnmatch.o EXTLIBS += -lws2_32 -lregex X = .exe diff --git a/git.c b/git.c index a291177701..f893f373e1 100644 --- a/git.c +++ b/git.c @@ -280,6 +280,15 @@ static void handle_internal_command(int argc, const char **argv, char **envp) }; 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]; @@ -325,6 +334,16 @@ int main(int argc, const char **argv, char **envp) cmd = slash; } +#ifdef __MINGW32__ + slash = strrchr(cmd, '\\'); + if (slash) { + *slash++ = 0; + if (cmd[1] == ':') + exec_path = cmd; + cmd = slash; + } +#endif + /* * "git-xxxx" is the same as "git xxxx", but we obviously: *