squash! Windows: use %PROGRAMDATA%\Git\config as Windows-wide configuration

On XP, there is no %PROGRAMDATA%, therefore we need to use
"%ALLUSERSPROFILE%\Application Data\Git\config" in those setups.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2015-04-23 16:55:53 +01:00
parent cc9730bd66
commit 4583e6bebd

View File

@@ -1,6 +1,7 @@
#include "../git-compat-util.h"
#include "win32.h"
#include <conio.h>
#include <shlobj.h>
#include <wchar.h>
#include "../strbuf.h"
#include "../run-command.h"
@@ -2382,8 +2383,16 @@ void mingw_startup()
const char *windows_wide_config(void)
{
static struct strbuf windows_wide = STRBUF_INIT;
if (!windows_wide.len)
strbuf_addf(&windows_wide,
"%s\\Git\\config", getenv("PROGRAMDATA"));
return windows_wide.buf;
if (!windows_wide.len) {
char wbuffer[MAX_PATH];
if (SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL,
SHGFP_TYPE_CURRENT, wbuffer) != S_OK)
strbuf_addch(&windows_wide, '\0');
else {
char buffer[MAX_PATH];
xwcstoutf(buffer, wbuffer, sizeof(buffer));
strbuf_addf(&windows_wide, "%s\\Git\\config", buffer);
}
}
return *windows_wide.buf ? windows_wide.buf : NULL;
}