File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
#include "../git-compat-util.h"
2
2
#include "win32.h"
3
3
#include <conio.h>
4
+ #include <shlobj.h>
4
5
#include <wchar.h>
5
6
#include "../strbuf.h"
6
7
#include "../run-command.h"
@@ -2382,8 +2383,16 @@ void mingw_startup()
2382
2383
const char * windows_wide_config (void )
2383
2384
{
2384
2385
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 ;
2389
2398
}
You can’t perform that action at this time.
0 commit comments