config --get --path: check for unset $HOME
If $HOME is unset (as in some automated build situations), currently git config --path path.home "~" git config --path --get path.home segfaults. Error out with Failed to expand user dir in: '~/' instead. Reported-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
28bf4ba014
commit
79bf149061
2
path.c
2
path.c
@ -316,6 +316,8 @@ char *expand_user_path(const char *path)
|
||||
size_t username_len = first_slash - username;
|
||||
if (username_len == 0) {
|
||||
const char *home = getenv("HOME");
|
||||
if (!home)
|
||||
goto return_null;
|
||||
strbuf_add(&user_path, home, strlen(home));
|
||||
} else {
|
||||
struct passwd *pw = getpw_str(username, username_len);
|
||||
|
||||
Reference in New Issue
Block a user