Skip to content

Commit

Permalink
mingw: factor out Windows specific environment setup
Browse files Browse the repository at this point in the history
We will add more environment-related code to that new function
in the next patch.

Signed-off-by: Karsten Blees <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
kblees authored and gitster committed Jan 26, 2016
1 parent 888ab71 commit 02e6edc
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,22 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen)
return -1;
}

static void setup_windows_environment()
{
/* on Windows it is TMP and TEMP */
if (!getenv("TMPDIR")) {
const char *tmp = getenv("TMP");
if (!tmp)
tmp = getenv("TEMP");
if (tmp)
setenv("TMPDIR", tmp, 1);
}

/* simulate TERM to enable auto-color (see color.c) */
if (!getenv("TERM"))
setenv("TERM", "cygwin", 1);
}

/*
* Disable MSVCRT command line wildcard expansion (__getmainargs called from
* mingw startup code, see init.c in mingw runtime).
Expand Down Expand Up @@ -2122,19 +2138,7 @@ void mingw_startup()
qsort(environ, i, sizeof(char*), compareenv);

/* fix Windows specific environment settings */

/* on Windows it is TMP and TEMP */
if (!mingw_getenv("TMPDIR")) {
const char *tmp = mingw_getenv("TMP");
if (!tmp)
tmp = mingw_getenv("TEMP");
if (tmp)
setenv("TMPDIR", tmp, 1);
}

/* simulate TERM to enable auto-color (see color.c) */
if (!getenv("TERM"))
setenv("TERM", "cygwin", 1);
setup_windows_environment();

/* initialize critical section for waitpid pinfo_t list */
InitializeCriticalSection(&pinfo_cs);
Expand Down

0 comments on commit 02e6edc

Please sign in to comment.