Imported Upstream version 2.10.4
[platform/upstream/git.git] / t / t0001-init.sh
index e62c0ff..a6fdd5e 100755 (executable)
@@ -12,6 +12,13 @@ check_config () {
                echo "expected a directory $1, a file $1/config and $1/refs"
                return 1
        fi
+
+       if test_have_prereq POSIXPERM && test -x "$1/config"
+       then
+               echo "$1/config is executable?"
+               return 1
+       fi
+
        bare=$(cd "$1" && git config --bool core.bare)
        worktree=$(cd "$1" && git config core.worktree) ||
        worktree=unset
@@ -80,6 +87,21 @@ test_expect_success 'plain nested in bare through aliased command' '
        check_config bare-ancestor-aliased.git/plain-nested/.git false unset
 '
 
+test_expect_success 'No extra GIT_* on alias scripts' '
+       write_script script <<-\EOF &&
+       env |
+               sed -n \
+                       -e "/^GIT_PREFIX=/d" \
+                       -e "/^GIT_TEXTDOMAINDIR=/d" \
+                       -e "/^GIT_/s/=.*//p" |
+               sort
+       EOF
+       ./script >expected &&
+       git config alias.script \!./script &&
+       ( mkdir sub && cd sub && git script >../actual ) &&
+       test_cmp expected actual
+'
+
 test_expect_success 'plain with GIT_WORK_TREE' '
        mkdir plain-wt &&
        test_must_fail env GIT_WORK_TREE="$(pwd)/plain-wt" git init plain-wt
@@ -195,8 +217,8 @@ test_expect_success 'init honors global core.sharedRepository' '
        x$(git config -f shared-honor-global/.git/config core.sharedRepository)
 '
 
-test_expect_success 'init rejects insanely long --template' '
-       test_must_fail git init --template=$(printf "x%09999dx" 1) test
+test_expect_success 'init allows insanely long --template' '
+       git init --template=$(printf "x%09999dx" 1) test
 '
 
 test_expect_success 'init creates a new directory' '
@@ -332,4 +354,34 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
        test_path_is_dir realgitdir/refs
 '
 
+# Tests for the hidden file attribute on windows
+is_hidden () {
+       # Use the output of `attrib`, ignore the absolute path
+       case "$(attrib "$1")" in *H*?:*) return 0;; esac
+       return 1
+}
+
+test_expect_success MINGW '.git hidden' '
+       rm -rf newdir &&
+       (
+               unset GIT_DIR GIT_WORK_TREE
+               mkdir newdir &&
+               cd newdir &&
+               git init &&
+               is_hidden .git
+       ) &&
+       check_config newdir/.git false unset
+'
+
+test_expect_success MINGW 'bare git dir not hidden' '
+       rm -rf newdir &&
+       (
+               unset GIT_DIR GIT_WORK_TREE GIT_CONFIG
+               mkdir newdir &&
+               cd newdir &&
+               git --bare init
+       ) &&
+       ! is_hidden newdir
+'
+
 test_done