mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
Merge branch 'jk/config-path-include-fix'
include.path variable (or any variable that expects a path that can use ~username expansion) in the configuration file is not a boolean, but the code failed to check it. * jk/config-path-include-fix: handle_path_include: don't look at NULL value expand_user_path: do not look at NULL path
This commit is contained in:
commit
bfef492d76
6
config.c
6
config.c
|
@ -84,8 +84,12 @@ static int handle_path_include(const char *path, struct config_include_data *inc
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
char *expanded = expand_user_path(path);
|
char *expanded;
|
||||||
|
|
||||||
|
if (!path)
|
||||||
|
return config_error_nonbool("include.path");
|
||||||
|
|
||||||
|
expanded = expand_user_path(path);
|
||||||
if (!expanded)
|
if (!expanded)
|
||||||
return error("Could not expand include path '%s'", path);
|
return error("Could not expand include path '%s'", path);
|
||||||
path = expanded;
|
path = expanded;
|
||||||
|
|
2
path.c
2
path.c
|
@ -265,12 +265,12 @@ static struct passwd *getpw_str(const char *username, size_t len)
|
||||||
char *expand_user_path(const char *path)
|
char *expand_user_path(const char *path)
|
||||||
{
|
{
|
||||||
struct strbuf user_path = STRBUF_INIT;
|
struct strbuf user_path = STRBUF_INIT;
|
||||||
const char *first_slash = strchrnul(path, '/');
|
|
||||||
const char *to_copy = path;
|
const char *to_copy = path;
|
||||||
|
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
goto return_null;
|
goto return_null;
|
||||||
if (path[0] == '~') {
|
if (path[0] == '~') {
|
||||||
|
const char *first_slash = strchrnul(path, '/');
|
||||||
const char *username = path + 1;
|
const char *username = path + 1;
|
||||||
size_t username_len = first_slash - username;
|
size_t username_len = first_slash - username;
|
||||||
if (username_len == 0) {
|
if (username_len == 0) {
|
||||||
|
|
Loading…
Reference in a new issue