[PATCH 2/5] Fix setup of $GIT_DIR in git-sh-setup.sh
- From
- Lars Hjemli <hjemli@gmail.com>
- Date
- Feb 17, 2008, 22:14 UTC
- Message-ID
- <1203286456-26033-3-git-send-email-hjemli@gmail.com>
- In-Reply-To
- <1203286456-26033-2-git-send-email-hjemli@gmail.com>
Since .git can be a file refering to the real GIT_DIR, git-sh-setup needs to use 'git rev-parse --git-dir' to obtain the location of the git repository.
Signed-off-by: Lars Hjemli <hjemli@gmail.com> --- git-sh-setup.sh | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh index f388275..a7dbce2 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -127,20 +127,18 @@ get_author_ident_from_commit () { # if we require to be in a git repository. if test -z "$NONGIT_OK" then + GIT_DIR=$(git rev-parse --git-dir) || { + exit=$? + echo >&2 "Failed to find a valid git directory." + exit $exit + } if [ -z "$SUBDIRECTORY_OK" ] then - : ${GIT_DIR=.git} 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 } - else - GIT_DIR=$(git rev-parse --git-dir) || { - exit=$? - echo >&2 "Failed to find a valid git directory." - exit $exit - } fi test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || { echo >&2 "Unable to determine absolute path of git directory"
-- 1.5.4.1.188.gdfa6c