summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-07-26 15:06:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-07-27 17:58:46 (GMT)
commit79bf149061fa29482512d903192a0d929e82872b (patch)
tree2eab8bb4dec251568078a3c8074bbdecc8b45c67 /path.c
parent28bf4ba014c9b41679f41580fa9e1cc294b240d9 (diff)
downloadgit-79bf149061fa29482512d903192a0d929e82872b.zip
git-79bf149061fa29482512d903192a0d929e82872b.tar.gz
git-79bf149061fa29482512d903192a0d929e82872b.tar.bz2
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>
Diffstat (limited to 'path.c')
-rw-r--r--path.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/path.c b/path.c
index aaa9345..f6226fc 100644
--- a/path.c
+++ b/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);