Skip to content

Commit cdf5ae9

Browse files
committed
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.
1 parent 2d08ead commit cdf5ae9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libgit2/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ static int git_config__parse_path(git_str *out, const char *value)
860860
return -1;
861861
}
862862

863-
return git_sysdir_expand_global_file(out, value[1] ? &value[2] : NULL);
863+
return git_sysdir_expand_homedir_file(out, value[1] ? &value[2] : NULL);
864864
}
865865

866866
return git_str_sets(out, value);

src/libgit2/config_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ static int included_path(git_str *out, const char *dir, const char *path)
528528
{
529529
/* From the user's home */
530530
if (path[0] == '~' && path[1] == '/')
531-
return git_sysdir_expand_global_file(out, &path[1]);
531+
return git_sysdir_expand_homedir_file(out, &path[1]);
532532

533533
return git_fs_path_join_unrooted(out, path, dir, NULL);
534534
}
@@ -616,7 +616,7 @@ static int do_match_gitdir(
616616
git_fs_path_dirname_r(&pattern, cfg_file);
617617
git_str_joinpath(&pattern, pattern.ptr, condition + 2);
618618
} else if (condition[0] == '~' && git_fs_path_is_dirsep(condition[1]))
619-
git_sysdir_expand_global_file(&pattern, condition + 1);
619+
git_sysdir_expand_homedir_file(&pattern, condition + 1);
620620
else if (!git_fs_path_is_absolute(condition))
621621
git_str_joinpath(&pattern, "**", condition);
622622
else

0 commit comments

Comments
 (0)