File tree 5 files changed +34
-1
lines changed
5 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ the Git commands' behavior. The `.git/config` file in each repository
6
6
is used to store the configuration for that repository, and
7
7
`$HOME/.gitconfig` is used to store a per-user configuration as
8
8
fallback values for the `.git/config` file. The file `/etc/gitconfig`
9
- can be used to store a system-wide default configuration.
9
+ can be used to store a system-wide default configuration. On Windows,
10
+ configuration can also be stored in `C:\ProgramData\Git\config`; This
11
+ file will be used also by libgit2-based software.
10
12
11
13
The configuration variables are used by both the Git plumbing
12
14
and the porcelains. The variables are divided into sections, wherein
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"
@@ -2378,3 +2379,20 @@ void mingw_startup()
2378
2379
/* init length of current directory for handle_long_path */
2379
2380
current_directory_len = GetCurrentDirectoryW (0 , NULL );
2380
2381
}
2382
+
2383
+ const char * windows_wide_config (void )
2384
+ {
2385
+ static struct strbuf windows_wide = STRBUF_INIT ;
2386
+ if (!windows_wide .len ) {
2387
+ wchar_t 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 ;
2398
+ }
Original file line number Diff line number Diff line change @@ -392,6 +392,8 @@ static inline char *mingw_find_last_dir_sep(const char *path)
392
392
int mingw_offset_1st_component (const char * path );
393
393
#define offset_1st_component mingw_offset_1st_component
394
394
#define PATH_SEP ';'
395
+ extern const char * windows_wide_config (void );
396
+ #define git_super_config windows_wide_config
395
397
#ifndef __MINGW64_VERSION_MAJOR
396
398
#define PRIuMAX "I64u"
397
399
#define PRId64 "I64d"
Original file line number Diff line number Diff line change @@ -1204,11 +1204,18 @@ int git_config_system(void)
1204
1204
int git_config_early (config_fn_t fn , void * data , const char * repo_config )
1205
1205
{
1206
1206
int ret = 0 , found = 0 ;
1207
+ const char * super_config = git_super_config ();
1207
1208
char * xdg_config = NULL ;
1208
1209
char * user_config = NULL ;
1209
1210
1210
1211
home_config_paths (& user_config , & xdg_config , "config" );
1211
1212
1213
+ if (super_config && git_config_system () &&
1214
+ !access (super_config , R_OK )) {
1215
+ ret += git_config_from_file (fn , super_config , data );
1216
+ found += 1 ;
1217
+ }
1218
+
1212
1219
if (git_config_system () && !access_or_die (git_etc_gitconfig (), R_OK , 0 )) {
1213
1220
ret += git_config_from_file (fn , git_etc_gitconfig (),
1214
1221
data );
Original file line number Diff line number Diff line change @@ -310,6 +310,10 @@ static inline char *git_find_last_dir_sep(const char *path)
310
310
#define find_last_dir_sep git_find_last_dir_sep
311
311
#endif
312
312
313
+ #ifndef git_super_config
314
+ #define git_super_config () NULL
315
+ #endif
316
+
313
317
#if defined(__HP_cc ) && (__HP_cc >= 61000 )
314
318
#define NORETURN __attribute__((noreturn))
315
319
#define NORETURN_PTR
You can’t perform that action at this time.
0 commit comments