config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSD
This variable is added [1] with the assumption that on a sane system, fopen(<dir>, "r") should return NULL. Linux and FreeBSD do not meet this expectation while at least Windows and AIX do. Let's make sure they behave the same way. I only tested one version on Linux (4.7.0 with glibc 2.22) and FreeBSD (11.0) but since GNU/kFreeBSD is fbsd kernel with gnu userspace, I'm pretty sure it shares the same problem. [1] cba22528fa (Add compat/fopen.c which returns NULL on attempt to open directory - 2008-02-08) Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 3, 2017 at 17:16 UTC
e2d90fd1c33ae57e4a6da5729ae53876107b3463
2 files changed
+11
config.mak.uname
+3
@@ -36,6 +36,7 @@ ifeq ($(uname_S),Linux)
36
NEEDS_LIBRT = YesPlease
37
HAVE_GETDELIM = YesPlease
38
SANE_TEXT_GREP=-a
39
+ FREAD_READS_DIRECTORIES = UnfortunatelyYes
40
endif
41
ifeq ($(uname_S),GNU/kFreeBSD)
42
HAVE_ALLOCA_H = YesPlease
@@ -43,6 +44,7 @@ ifeq ($(uname_S),GNU/kFreeBSD)
44
HAVE_PATHS_H = YesPlease
45
DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
46
LIBC_CONTAINS_LIBINTL = YesPlease
47
+ FREAD_READS_DIRECTORIES = UnfortunatelyYes
48
endif
49
ifeq ($(uname_S),UnixWare)
50
CC = cc
@@ -201,6 +203,7 @@ ifeq ($(uname_S),FreeBSD)
203
GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
204
HAVE_BSD_SYSCTL = YesPlease
205
PAGER_ENV = LESS=FRX LV=-c MORE=FRX
206
+ FREAD_READS_DIRECTORIES = UnfortunatelyYes
207
endif
208
ifeq ($(uname_S),OpenBSD)
209
NO_STRCASESTR = YesPlease
t/t1308-config-set.sh
+8
@@ -183,6 +183,14 @@ test_expect_success 'proper error on non-existent files' '
183
test_cmp expect actual
184
'
185
186
+test_expect_success 'proper error on directory "files"' '
187
+ echo "Error (-1) reading configuration file a-directory." >expect &&
188
+ mkdir a-directory &&
189
+ test_expect_code 2 test-config configset_get_value foo.bar a-directory 2>output &&
190
+ grep "^Error" output >actual &&
191
+ test_cmp expect actual
192
+'
193
+
194
test_expect_success POSIXPERM,SANITY 'proper error on non-accessible files' '
195
chmod -r .git/config &&
196
test_when_finished "chmod +r .git/config" &&