mirror of
https://github.com/git-for-windows/git.git
synced 2025-12-15 12:58:18 -06:00
Merge branch 'Fallback-to-AppData-if-XDG-CONFIG-HOME-is-unset'
This topic branch adds support for a more Windows-native user-wide config file than `XDG_CONFIG_HOME` (or `~/.config/`) will ever be. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
commit
9d13cd3c3b
23
path.c
23
path.c
@ -1480,6 +1480,7 @@ int looks_like_command_line_option(const char *str)
|
|||||||
char *xdg_config_home_for(const char *subdir, const char *filename)
|
char *xdg_config_home_for(const char *subdir, const char *filename)
|
||||||
{
|
{
|
||||||
const char *home, *config_home;
|
const char *home, *config_home;
|
||||||
|
char *home_config = NULL;
|
||||||
|
|
||||||
assert(subdir);
|
assert(subdir);
|
||||||
assert(filename);
|
assert(filename);
|
||||||
@ -1488,10 +1489,26 @@ char *xdg_config_home_for(const char *subdir, const char *filename)
|
|||||||
return mkpathdup("%s/%s/%s", config_home, subdir, filename);
|
return mkpathdup("%s/%s/%s", config_home, subdir, filename);
|
||||||
|
|
||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
if (home)
|
if (home && *home)
|
||||||
return mkpathdup("%s/.config/%s/%s", home, subdir, filename);
|
home_config = mkpathdup("%s/.config/%s/%s", home, subdir, filename);
|
||||||
|
|
||||||
return NULL;
|
#ifdef WIN32
|
||||||
|
{
|
||||||
|
const char *appdata = getenv("APPDATA");
|
||||||
|
if (appdata && *appdata) {
|
||||||
|
char *appdata_config = mkpathdup("%s/Git/%s", appdata, filename);
|
||||||
|
if (file_exists(appdata_config)) {
|
||||||
|
if (home_config && file_exists(home_config))
|
||||||
|
warning("'%s' was ignored because '%s' exists.", home_config, appdata_config);
|
||||||
|
free(home_config);
|
||||||
|
return appdata_config;
|
||||||
|
}
|
||||||
|
free(appdata_config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return home_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *xdg_config_home(const char *filename)
|
char *xdg_config_home(const char *filename)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user