Merge branch 'hv/submodule-path-unmatch' into maint-1.7.11
[git.git] / git-sh-setup.sh
index 7b3ae75d7a631fb07404ab85fa6d43ada74d8512..ee0e0bc045bb7d92045a3afb0a042748834e6163 100644 (file)
@@ -9,8 +9,12 @@
 # you would cause "cd" to be taken to unexpected places.  If you
 # like CDPATH, define it for your interactive shell sessions without
 # exporting it.
+# But we protect ourselves from such a user mistake nevertheless.
 unset CDPATH
 
+# Similarly for IFS
+unset IFS
+
 git_broken_path_fix () {
        case ":$PATH:" in
        *:$1:*) : ok ;;
@@ -218,27 +222,8 @@ clear_local_git_env() {
        unset $(git rev-parse --local-env-vars)
 }
 
-# Make sure we are in a valid repository of a vintage we understand,
-# if we require to be in a git repository.
-if test -z "$NONGIT_OK"
-then
-       GIT_DIR=$(git rev-parse --git-dir) || exit
-       if [ -z "$SUBDIRECTORY_OK" ]
-       then
-               test -z "$(git rev-parse --show-cdup)" || {
-                       exit=$?
-                       echo >&2 "You need to run this command from the toplevel of the working tree."
-                       exit $exit
-               }
-       fi
-       test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
-               echo >&2 "Unable to determine absolute path of git directory"
-               exit 1
-       }
-       : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
-fi
 
-# Fix some commands on Windows
+# Platform specific tweaks to work around some commands
 case $(uname -s) in
 *MINGW*)
        # Windows has its own (incompatible) sort and find
@@ -269,3 +254,23 @@ case $(uname -s) in
                return 1
        }
 esac
+
+# Make sure we are in a valid repository of a vintage we understand,
+# if we require to be in a git repository.
+if test -z "$NONGIT_OK"
+then
+       GIT_DIR=$(git rev-parse --git-dir) || exit
+       if [ -z "$SUBDIRECTORY_OK" ]
+       then
+               test -z "$(git rev-parse --show-cdup)" || {
+                       exit=$?
+                       echo >&2 "You need to run this command from the toplevel of the working tree."
+                       exit $exit
+               }
+       fi
+       test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
+               echo >&2 "Unable to determine absolute path of git directory"
+               exit 1
+       }
+       : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
+fi