X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=git-sh-setup.sh;h=770a86e2b7a5e517e51d9897b274b876a6b9e0e1;hb=b700086d840ceaee339f9f031be72b34e237f84f;hp=5d8e4e6c89f0471567a7aa1f07b054d8ac502e15;hpb=dc813f664d779330c392500a0f3b4d53893dc7ae;p=~andy%2Fgit diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 5d8e4e6c8..770a86e2b 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -218,27 +218,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 @@ -248,6 +229,10 @@ case $(uname -s) in find () { /usr/bin/find "$@" } + # git sees Windows-style pwd + pwd () { + builtin pwd -W + } is_absolute_path () { case "$1" in [/\\]* | [A-Za-z]:*) @@ -265,3 +250,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