Skip to content

Commit 00fb16b

Browse files
committed
Merge remote-tracking branch 'dscho/xp-config'
This topic branch supports a Windows-wide config on Windows XP, too. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents cc9730b + 4583e6b commit 00fb16b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

compat/mingw.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "../git-compat-util.h"
22
#include "win32.h"
33
#include <conio.h>
4+
#include <shlobj.h>
45
#include <wchar.h>
56
#include "../strbuf.h"
67
#include "../run-command.h"
@@ -2382,8 +2383,16 @@ void mingw_startup()
23822383
const char *windows_wide_config(void)
23832384
{
23842385
static struct strbuf windows_wide = STRBUF_INIT;
2385-
if (!windows_wide.len)
2386-
strbuf_addf(&windows_wide,
2387-
"%s\\Git\\config", getenv("PROGRAMDATA"));
2388-
return windows_wide.buf;
2386+
if (!windows_wide.len) {
2387+
char wbuffer[MAX_PATH];
2388+
if (SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL,
2389+
SHGFP_TYPE_CURRENT, wbuffer) != S_OK)
2390+
strbuf_addch(&windows_wide, '\0');
2391+
else {
2392+
char buffer[MAX_PATH];
2393+
xwcstoutf(buffer, wbuffer, sizeof(buffer));
2394+
strbuf_addf(&windows_wide, "%s\\Git\\config", buffer);
2395+
}
2396+
}
2397+
return *windows_wide.buf ? windows_wide.buf : NULL;
23892398
}

0 commit comments

Comments
 (0)