mirror of
https://github.com/git/git.git
synced 2026-02-15 20:34:58 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user