diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2010-07-26 10:06:51 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-07-27 10:58:46 -0700 |
commit | 79bf149061fa29482512d903192a0d929e82872b (patch) | |
tree | 2eab8bb4dec251568078a3c8074bbdecc8b45c67 /t/t1300-repo-config.sh | |
parent | 28bf4ba014c9b41679f41580fa9e1cc294b240d9 (diff) | |
download | git-79bf149061fa29482512d903192a0d929e82872b.tar.gz |
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 't/t1300-repo-config.sh')
-rwxr-xr-x | t/t1300-repo-config.sh | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index f11f98c3ce..7ddab5fb76 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -707,19 +707,41 @@ test_expect_success 'set --path' ' git config --path path.trailingtilde "foo~" && test_cmp expect .git/config' +if test "${HOME+set}" +then + test_set_prereq HOMEVAR +fi + cat >expect <<EOF $HOME/ /dev/null foo~ EOF -test_expect_success 'get --path' ' +test_expect_success HOMEVAR 'get --path' ' git config --get --path path.home > result && git config --get --path path.normal >> result && git config --get --path path.trailingtilde >> result && test_cmp expect result ' +cat >expect <<\EOF +/dev/null +foo~ +EOF + +test_expect_success 'get --path copes with unset $HOME' ' + ( + unset HOME; + test_must_fail git config --get --path path.home \ + >result 2>msg && + git config --get --path path.normal >>result && + git config --get --path path.trailingtilde >>result + ) && + grep "[Ff]ailed to expand.*~/" msg && + test_cmp expect result +' + rm .git/config git config quote.leading " test" |