config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSD
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Wed, 3 May 2017 10:16:48 +0000 (17:16 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 May 2017 03:33:55 +0000 (12:33 +0900)
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>
config.mak.uname
t/t1308-config-set.sh
index 399fe192719072691ebdbd7954fd8bd6cc12b96e..a25ffddb3e63548b923133e23b2420561be1aacd 100644 (file)
@@ -36,6 +36,7 @@ ifeq ($(uname_S),Linux)
        NEEDS_LIBRT = YesPlease
        HAVE_GETDELIM = YesPlease
        SANE_TEXT_GREP=-a
        NEEDS_LIBRT = YesPlease
        HAVE_GETDELIM = YesPlease
        SANE_TEXT_GREP=-a
+       FREAD_READS_DIRECTORIES = UnfortunatelyYes
 endif
 ifeq ($(uname_S),GNU/kFreeBSD)
        HAVE_ALLOCA_H = YesPlease
 endif
 ifeq ($(uname_S),GNU/kFreeBSD)
        HAVE_ALLOCA_H = YesPlease
@@ -43,6 +44,7 @@ ifeq ($(uname_S),GNU/kFreeBSD)
        HAVE_PATHS_H = YesPlease
        DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
        LIBC_CONTAINS_LIBINTL = YesPlease
        HAVE_PATHS_H = YesPlease
        DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
        LIBC_CONTAINS_LIBINTL = YesPlease
+       FREAD_READS_DIRECTORIES = UnfortunatelyYes
 endif
 ifeq ($(uname_S),UnixWare)
        CC = cc
 endif
 ifeq ($(uname_S),UnixWare)
        CC = cc
@@ -201,6 +203,7 @@ ifeq ($(uname_S),FreeBSD)
        GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
        HAVE_BSD_SYSCTL = YesPlease
        PAGER_ENV = LESS=FRX LV=-c MORE=FRX
        GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
        HAVE_BSD_SYSCTL = YesPlease
        PAGER_ENV = LESS=FRX LV=-c MORE=FRX
+       FREAD_READS_DIRECTORIES = UnfortunatelyYes
 endif
 ifeq ($(uname_S),OpenBSD)
        NO_STRCASESTR = YesPlease
 endif
 ifeq ($(uname_S),OpenBSD)
        NO_STRCASESTR = YesPlease
index ff50960ccaed9953c5738c9bbf602bf0d326e15a..72d5f1f931bcb4bb99596759e1eeac72da3b07c7 100755 (executable)
@@ -183,6 +183,14 @@ test_expect_success 'proper error on non-existent files' '
        test_cmp expect actual
 '
 
        test_cmp expect actual
 '
 
+test_expect_success 'proper error on directory "files"' '
+       echo "Error (-1) reading configuration file a-directory." >expect &&
+       mkdir a-directory &&
+       test_expect_code 2 test-config configset_get_value foo.bar a-directory 2>output &&
+       grep "^Error" output >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success POSIXPERM,SANITY 'proper error on non-accessible files' '
        chmod -r .git/config &&
        test_when_finished "chmod +r .git/config" &&
 test_expect_success POSIXPERM,SANITY 'proper error on non-accessible files' '
        chmod -r .git/config &&
        test_when_finished "chmod +r .git/config" &&