t0001: skip test with restrictive permissions if getpwd(3) respects them
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>
René Scharfe committed
Aug 7, 2017 at 13:04 UTC
bed67874e235e8f128607728f9a03c71e92cb955
1 file changed
+28
-2
t/t0001-init.sh
+28
-2
@@ -315,18 +315,44 @@ test_expect_success 'init with separate gitdir' '
315
test_path_is_dir realgitdir/refs
316
'
317
318
-test_expect_success 'init in long base path' '
318
+test_lazy_prereq GETCWD_IGNORES_PERMS '
319
+ base=GETCWD_TEST_BASE_DIR &&
320
+ mkdir -p $base/dir &&
321
+ chmod 100 $base ||
322
+ error "bug in test script: cannot prepare $base"
323
+
324
+ (cd $base/dir && /bin/pwd -P)
325
+ status=$?
326
+
327
+ chmod 700 $base &&
328
+ rm -rf $base ||
329
+ error "bug in test script: cannot clean $base"
330
+ return $status
331
+'
332
+
333
+check_long_base_path () {
334
# exceed initial buffer size of strbuf_getcwd()
335
component=123456789abcdef &&
336
test_when_finished "chmod 0700 $component; rm -rf $component" &&
337
p31=$component/$component &&
338
p127=$p31/$p31/$p31/$p31 &&
339
mkdir -p $p127 &&
325
- chmod 0111 $component &&
340
+ if test $# = 1
341
+ then
342
+ chmod $1 $component
343
+ fi &&
344
(
345
cd $p127 &&
346
git init newdir
347
)
348
+}
349
+
350
+test_expect_success 'init in long base path' '
351
+ check_long_base_path
352
+'
353
+
354
+test_expect_success GETCWD_IGNORES_PERMS 'init in long restricted base path' '
355
+ check_long_base_path 0111
356
'
357
358
test_expect_success 're-init on .git file' '