strip extension and handle DRIVE: notation

This commit is contained in:
Johannes Schindelin
2006-09-18 17:02:59 +02:00
committed by Johannes Sixt
parent 8d1bfddd0c
commit 9c6663c419
2 changed files with 21 additions and 1 deletions

View File

@@ -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

19
git.c
View File

@@ -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:
*