Skip to content

Commit

Permalink
Merge remote-tracking branch 'dscho/xp-config'
Browse files Browse the repository at this point in the history
This topic branch supports a Windows-wide config on Windows XP, too.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Apr 25, 2015
2 parents cc9730b + 4583e6b commit 00fb16b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions compat/mingw.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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;
}

0 comments on commit 00fb16b

Please sign in to comment.