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>
This commit is contained in:
parent
ee4f06c0a6
commit
4d6d6d2d3f
@ -127,20 +127,14 @@ get_author_ident_from_commit () {
|
|||||||
# if we require to be in a git repository.
|
# if we require to be in a git repository.
|
||||||
if test -z "$NONGIT_OK"
|
if test -z "$NONGIT_OK"
|
||||||
then
|
then
|
||||||
|
GIT_DIR=$(git rev-parse --git-dir) || exit
|
||||||
if [ -z "$SUBDIRECTORY_OK" ]
|
if [ -z "$SUBDIRECTORY_OK" ]
|
||||||
then
|
then
|
||||||
: ${GIT_DIR=.git}
|
|
||||||
test -z "$(git rev-parse --show-cdup)" || {
|
test -z "$(git rev-parse --show-cdup)" || {
|
||||||
exit=$?
|
exit=$?
|
||||||
echo >&2 "You need to run this command from the toplevel of the working tree."
|
echo >&2 "You need to run this command from the toplevel of the working tree."
|
||||||
exit $exit
|
exit $exit
|
||||||
}
|
}
|
||||||
else
|
|
||||||
GIT_DIR=$(git rev-parse --git-dir) || {
|
|
||||||
exit=$?
|
|
||||||
echo >&2 "Failed to find a valid git directory."
|
|
||||||
exit $exit
|
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
|
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
|
||||||
echo >&2 "Unable to determine absolute path of git directory"
|
echo >&2 "Unable to determine absolute path of git directory"
|
||||||
|
Loading…
Reference in New Issue
Block a user