]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-sh-setup.sh
Merge branch 'sg/rerere-cleanup'
[git.git] / git-sh-setup.sh
index a44b1c74a38d6310d7a1bde969cbbcb51f977188..838233926f7ed07f781f2eb2e7547a2a5a086071 100755 (executable)
@@ -32,15 +32,16 @@ if test -n "$OPTIONS_SPEC"; then
                echo exit $?
        )"
 else
+       dashless=$(basename "$0" | sed -e 's/-/ /')
        usage() {
-               die "Usage: $0 $USAGE"
+               die "Usage: $dashless $USAGE"
        }
 
        if [ -z "$LONG_USAGE" ]
        then
-               LONG_USAGE="Usage: $0 $USAGE"
+               LONG_USAGE="Usage: $dashless $USAGE"
        else
-               LONG_USAGE="Usage: $0 $USAGE
+               LONG_USAGE="Usage: $dashless $USAGE
 
 $LONG_USAGE"
        fi
@@ -84,7 +85,13 @@ cd_to_toplevel () {
        cdup=$(git rev-parse --show-cdup)
        if test ! -z "$cdup"
        then
-               cd "$cdup" || {
+               # The "-P" option says to follow "physical" directory
+               # structure instead of following symbolic links.  When cdup is
+               # "../", this means following the ".." entry in the current
+               # directory instead textually removing a symlink path element
+               # from the PWD shell variable.  The "-P" behavior is more
+               # consistent with the C-style chdir used by most of Git.
+               cd -P "$cdup" || {
                        echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
                        exit 1
                }
@@ -142,3 +149,16 @@ then
        }
        : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
 fi
+
+# Fix some commands on Windows
+case $(uname -s) in
+*MINGW*)
+       # Windows has its own (incompatible) sort and find
+       sort () {
+               /usr/bin/sort "$@"
+       }
+       find () {
+               /usr/bin/find "$@"
+       }
+       ;;
+esac