File tree Expand file tree Collapse file tree 5 files changed +34
-1
lines changed
Expand file tree Collapse file tree 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
66is used to store the configuration for that repository, and
77`$HOME/.gitconfig` is used to store a per-user configuration as
88fallback 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.
1012
1113The configuration variables are used by both the Git plumbing
1214and the porcelains. The variables are divided into sections, wherein
Original file line number Diff line number Diff line change 11#include "../git-compat-util.h"
22#include "win32.h"
33#include <conio.h>
4+ #include <shlobj.h>
45#include <wchar.h>
56#include "../strbuf.h"
67#include "../run-command.h"
@@ -2378,3 +2379,20 @@ void mingw_startup()
23782379 /* init length of current directory for handle_long_path */
23792380 current_directory_len = GetCurrentDirectoryW (0 , NULL );
23802381}
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)
392392int mingw_offset_1st_component (const char * path );
393393#define offset_1st_component mingw_offset_1st_component
394394#define PATH_SEP ';'
395+ extern const char * windows_wide_config (void );
396+ #define git_super_config windows_wide_config
395397#ifndef __MINGW64_VERSION_MAJOR
396398#define PRIuMAX "I64u"
397399#define PRId64 "I64d"
Original file line number Diff line number Diff line change @@ -1204,11 +1204,18 @@ int git_config_system(void)
12041204int git_config_early (config_fn_t fn , void * data , const char * repo_config )
12051205{
12061206 int ret = 0 , found = 0 ;
1207+ const char * super_config = git_super_config ();
12071208 char * xdg_config = NULL ;
12081209 char * user_config = NULL ;
12091210
12101211 home_config_paths (& user_config , & xdg_config , "config" );
12111212
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+
12121219 if (git_config_system () && !access_or_die (git_etc_gitconfig (), R_OK , 0 )) {
12131220 ret += git_config_from_file (fn , git_etc_gitconfig (),
12141221 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)
310310#define find_last_dir_sep git_find_last_dir_sep
311311#endif
312312
313+ #ifndef git_super_config
314+ #define git_super_config () NULL
315+ #endif
316+
313317#if defined(__HP_cc ) && (__HP_cc >= 61000 )
314318#define NORETURN __attribute__((noreturn))
315319#define NORETURN_PTR
You can’t perform that action at this time.
0 commit comments