Commit cdf5ae9f by Edward Thomson

config: use home directory for `~` includes

Users can specify a config file to be included in the home directory
using `~/filename` syntax. Instead of looking in the global
configuration location (which may be overridden), use the user's
_actual_ home directory. This allows callers to change the global
configuration location separately from the home directory.
parent 2d08ead9
......@@ -860,7 +860,7 @@ static int git_config__parse_path(git_str *out, const char *value)
return -1;
}
return git_sysdir_expand_global_file(out, value[1] ? &value[2] : NULL);
return git_sysdir_expand_homedir_file(out, value[1] ? &value[2] : NULL);
}
return git_str_sets(out, value);
......
......@@ -528,7 +528,7 @@ static int included_path(git_str *out, const char *dir, const char *path)
{
/* From the user's home */
if (path[0] == '~' && path[1] == '/')
return git_sysdir_expand_global_file(out, &path[1]);
return git_sysdir_expand_homedir_file(out, &path[1]);
return git_fs_path_join_unrooted(out, path, dir, NULL);
}
......@@ -616,7 +616,7 @@ static int do_match_gitdir(
git_fs_path_dirname_r(&pattern, cfg_file);
git_str_joinpath(&pattern, pattern.ptr, condition + 2);
} else if (condition[0] == '~' && git_fs_path_is_dirsep(condition[1]))
git_sysdir_expand_global_file(&pattern, condition + 1);
git_sysdir_expand_homedir_file(&pattern, condition + 1);
else if (!git_fs_path_is_absolute(condition))
git_str_joinpath(&pattern, "**", condition);
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment