Simplify setup of $GIT_DIR in git-sh-setup.sh
Using 'git rev-parse --git-dir' makes the code shorter and more future- proof. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lars Hjemli committed
Feb 18, 2008 at 11:44 UTC
4d6d6d2d3f778b892f2481969e530ff67ee0aa6c
1 file changed
+1
-7
git-sh-setup.sh
+1
-7
@@ -127,20 +127,14 @@ get_author_ident_from_commit () {
127
# if we require to be in a git repository.
128
if test -z "$NONGIT_OK"
129
then
130
+ GIT_DIR=$(git rev-parse --git-dir) || exit
131
if [ -z "$SUBDIRECTORY_OK" ]
132
then
132
- : ${GIT_DIR=.git}
133
test -z "$(git rev-parse --show-cdup)" || {
134
exit=$?
135
echo >&2 "You need to run this command from the toplevel of the working tree."
136
exit $exit
137
}
138
- else
139
- GIT_DIR=$(git rev-parse --git-dir) || {
140
- exit=$?
141
- echo >&2 "Failed to find a valid git directory."
142
- exit $exit
143
- }
138
fi
139
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
140
echo >&2 "Unable to determine absolute path of git directory"