]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t0001: skip test with restrictive permissions if getpwd(3) respects them
authorRené Scharfe <l.s.r@web.de>
Mon, 7 Aug 2017 11:04:18 +0000 (13:04 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Aug 2017 17:35:18 +0000 (10:35 -0700)
The sub-test "init in long base path" in t0001 checks the ability to
handle long base paths with restrictive permissions (--x).  On OpenBSD
getcwd(3) fails in that case even for short paths.  Check the two
aspects separately by trying to use a long base path both with and
without execute-only permissions.  Only attempt the former if we know
that getcwd(3) doesn't care.

Original-patch-by: David Coppa <dcoppa@openbsd.org>
Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0001-init.sh

index c4814d248fc96e7dc0177b6987baa18853c6213c..86c1a51654fa6c1b049a313fe8d880c6a266ee62 100755 (executable)
@@ -315,18 +315,44 @@ test_expect_success 'init with separate gitdir' '
        test_path_is_dir realgitdir/refs
 '
 
-test_expect_success 'init in long base path' '
+test_lazy_prereq GETCWD_IGNORES_PERMS '
+       base=GETCWD_TEST_BASE_DIR &&
+       mkdir -p $base/dir &&
+       chmod 100 $base ||
+       error "bug in test script: cannot prepare $base"
+
+       (cd $base/dir && /bin/pwd -P)
+       status=$?
+
+       chmod 700 $base &&
+       rm -rf $base ||
+       error "bug in test script: cannot clean $base"
+       return $status
+'
+
+check_long_base_path () {
        # exceed initial buffer size of strbuf_getcwd()
        component=123456789abcdef &&
        test_when_finished "chmod 0700 $component; rm -rf $component" &&
        p31=$component/$component &&
        p127=$p31/$p31/$p31/$p31 &&
        mkdir -p $p127 &&
-       chmod 0111 $component &&
+       if test $# = 1
+       then
+               chmod $1 $component
+       fi &&
        (
                cd $p127 &&
                git init newdir
        )
+}
+
+test_expect_success 'init in long base path' '
+       check_long_base_path
+'
+
+test_expect_success GETCWD_IGNORES_PERMS 'init in long restricted base path' '
+       check_long_base_path 0111
 '
 
 test_expect_success 're-init on .git file' '