Skip to content

Commit e2d90fd

Browse files
pcloudsgitster
authored andcommitted
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] cba2252 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 02912f4 commit e2d90fd

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

config.mak.uname

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ ifeq ($(uname_S),Linux)
3636
NEEDS_LIBRT = YesPlease
3737
HAVE_GETDELIM = YesPlease
3838
SANE_TEXT_GREP=-a
39+
FREAD_READS_DIRECTORIES = UnfortunatelyYes
3940
endif
4041
ifeq ($(uname_S),GNU/kFreeBSD)
4142
HAVE_ALLOCA_H = YesPlease
4243
NO_STRLCPY = YesPlease
4344
HAVE_PATHS_H = YesPlease
4445
DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
4546
LIBC_CONTAINS_LIBINTL = YesPlease
47+
FREAD_READS_DIRECTORIES = UnfortunatelyYes
4648
endif
4749
ifeq ($(uname_S),UnixWare)
4850
CC = cc
@@ -201,6 +203,7 @@ ifeq ($(uname_S),FreeBSD)
201203
GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
202204
HAVE_BSD_SYSCTL = YesPlease
203205
PAGER_ENV = LESS=FRX LV=-c MORE=FRX
206+
FREAD_READS_DIRECTORIES = UnfortunatelyYes
204207
endif
205208
ifeq ($(uname_S),OpenBSD)
206209
NO_STRCASESTR = YesPlease

t/t1308-config-set.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ test_expect_success 'proper error on non-existent files' '
183183
test_cmp expect actual
184184
'
185185

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+
186194
test_expect_success POSIXPERM,SANITY 'proper error on non-accessible files' '
187195
chmod -r .git/config &&
188196
test_when_finished "chmod +r .git/config" &&

0 commit comments

Comments
 (0)