Skip to content

Commit 33e5880

Browse files
committed
Merge branch 'rs/obsd-getcwd-workaround'
Test portability fix for BSDs. * rs/obsd-getcwd-workaround: t0001: skip test with restrictive permissions if getpwd(3) respects them
2 parents 5696eb3 + bed6787 commit 33e5880

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

t/t0001-init.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,18 +315,44 @@ test_expect_success 'init with separate gitdir' '
315315
test_path_is_dir realgitdir/refs
316316
'
317317

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 () {
319334
# exceed initial buffer size of strbuf_getcwd()
320335
component=123456789abcdef &&
321336
test_when_finished "chmod 0700 $component; rm -rf $component" &&
322337
p31=$component/$component &&
323338
p127=$p31/$p31/$p31/$p31 &&
324339
mkdir -p $p127 &&
325-
chmod 0111 $component &&
340+
if test $# = 1
341+
then
342+
chmod $1 $component
343+
fi &&
326344
(
327345
cd $p127 &&
328346
git init newdir
329347
)
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
330356
'
331357

332358
test_expect_success 're-init on .git file' '

0 commit comments

Comments
 (0)