X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;ds=sidebyside;f=git-sh-setup.sh;h=2142308bcc6d2e2c4962859d18e12070cd4c1b1d;hb=dd6c1360b22ee89cb179e2a1fface98ecbeb7b3e;hp=a44b1c74a38d6310d7a1bde969cbbcb51f977188;hpb=32a27b56662b1c7aa13f98c95f170ba5290c7559;p=git.git diff --git a/git-sh-setup.sh b/git-sh-setup.sh index a44b1c74a..2142308bc 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -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,8 +85,27 @@ cd_to_toplevel () { cdup=$(git rev-parse --show-cdup) if test ! -z "$cdup" then - cd "$cdup" || { - echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree" + case "$cdup" in + /*) + # Not quite the same as if we did "cd -P '$cdup'" when + # $cdup contains ".." after symlink path components. + # Don't fix that case at least until Git switches to + # "cd -P" across the board. + phys="$cdup" + ;; + ..|../*|*/..|*/../*) + # Interpret $cdup relative to the physical, not logical, cwd. + # Probably /bin/pwd is more portable than passing -P to cd or pwd. + phys="$(unset PWD; /bin/pwd)/$cdup" + ;; + *) + # There's no "..", so no need to make things absolute. + phys="$cdup" + ;; + esac + + cd "$phys" || { + echo >&2 "Cannot chdir to $phys, the toplevel of the working tree" exit 1 } fi @@ -142,3 +162,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