From a4f86fdb808fef748b98a76503bfe9fbfd64f8db Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 13 Apr 2018 19:37:27 +0300 Subject: [PATCH] Feat(git-status.sh): Use `git rev-parse` to find git dir --- git-status.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-status.sh b/git-status.sh index ddab464..2b33f40 100755 --- a/git-status.sh +++ b/git-status.sh @@ -8,10 +8,11 @@ rm -rf "$STMP" && mkdir "$STMP" && GIT_INDEX_FILE="$STMP"/index && export GIT_INDEX_FILE && -if [ -d .git -a -f .git/index ]; then - cp -p .git/index $GIT_INDEX_FILE +GIT_DIR="`git rev-parse --git-dir`" +if [ -d "$GIT_DIR" -a -f "$GIT_DIR"/index ]; then + cp -p "$GIT_DIR"/index $GIT_INDEX_FILE else - echo "$0: `pwd` is not a git directory" >&2 + echo "$0: `pwd` is not a git repository/worktree" >&2 exit 1 fi && -- 2.39.5