Merge branch 'rs/sequencer-rewrite-file-cleanup' into maint
[gitweb.git] / t / t0001-init.sh
index e424de5363848233d2c1d9807df0a01411fd0d6d..c413bff9cf1f3a79ef494b39844c42d3a8c877f1 100755 (executable)
@@ -315,6 +315,46 @@ test_expect_success 'init with separate gitdir' '
        test_path_is_dir realgitdir/refs
 '
 
+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 &&
+       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' '
        ( cd newdir && git init )
 '
@@ -413,4 +453,16 @@ test_expect_success 're-init from a linked worktree' '
        )
 '
 
+test_expect_success MINGW 'redirect std handles' '
+       GIT_REDIRECT_STDOUT=output.txt git rev-parse --git-dir &&
+       test .git = "$(cat output.txt)" &&
+       test -z "$(GIT_REDIRECT_STDOUT=off git rev-parse --git-dir)" &&
+       test_must_fail env \
+               GIT_REDIRECT_STDOUT=output.txt \
+               GIT_REDIRECT_STDERR="2>&1" \
+               git rev-parse --git-dir --verify refs/invalid &&
+       printf ".git\nfatal: Needed a single revision\n" >expect &&
+       test_cmp expect output.txt
+'
+
 test_done