mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
path.c: remove home_config_paths()
home_config_paths() combines distinct functionality already implemented by expand_user_path() and xdg_config_home(), and it also hard-codes the path ~/.gitconfig, which makes it unsuitable to use for other home config file paths. Since its use will just add unnecessary complexity to the code, remove it. Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
1
cache.h
1
cache.h
@@ -808,7 +808,6 @@ enum scld_error safe_create_leading_directories(char *path);
|
|||||||
enum scld_error safe_create_leading_directories_const(const char *path);
|
enum scld_error safe_create_leading_directories_const(const char *path);
|
||||||
|
|
||||||
int mkdir_in_gitdir(const char *path);
|
int mkdir_in_gitdir(const char *path);
|
||||||
extern void home_config_paths(char **global, char **xdg, char *file);
|
|
||||||
extern char *expand_user_path(const char *path);
|
extern char *expand_user_path(const char *path);
|
||||||
const char *enter_repo(const char *path, int strict);
|
const char *enter_repo(const char *path, int strict);
|
||||||
static inline int is_absolute_path(const char *path)
|
static inline int is_absolute_path(const char *path)
|
||||||
|
|||||||
28
path.c
28
path.c
@@ -130,34 +130,6 @@ char *git_path(const char *fmt, ...)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void home_config_paths(char **global, char **xdg, char *file)
|
|
||||||
{
|
|
||||||
char *xdg_home = getenv("XDG_CONFIG_HOME");
|
|
||||||
char *home = getenv("HOME");
|
|
||||||
char *to_free = NULL;
|
|
||||||
|
|
||||||
if (!home) {
|
|
||||||
if (global)
|
|
||||||
*global = NULL;
|
|
||||||
} else {
|
|
||||||
if (!xdg_home) {
|
|
||||||
to_free = mkpathdup("%s/.config", home);
|
|
||||||
xdg_home = to_free;
|
|
||||||
}
|
|
||||||
if (global)
|
|
||||||
*global = mkpathdup("%s/.gitconfig", home);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xdg) {
|
|
||||||
if (!xdg_home)
|
|
||||||
*xdg = NULL;
|
|
||||||
else
|
|
||||||
*xdg = mkpathdup("%s/git/%s", xdg_home, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(to_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *git_path_submodule(const char *path, const char *fmt, ...)
|
char *git_path_submodule(const char *path, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char *pathname = get_pathname();
|
char *pathname = get_pathname();
|
||||||
|
|||||||
Reference in New Issue
Block a user