2005-07-08 17:57:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-11-24 08:12:11 +00:00
|
|
|
# This is included in commands that either have to be run from the toplevel
|
|
|
|
# of the repository, or with GIT_DIR environment variable properly.
|
|
|
|
# If the GIT_DIR does not look like the right correct git-repository,
|
|
|
|
# it dies.
|
2005-07-08 17:57:21 +00:00
|
|
|
|
2005-09-13 02:47:07 +00:00
|
|
|
# Having this variable in your environment would break scripts because
|
|
|
|
# you would cause "cd" to be be taken to unexpected places. If you
|
|
|
|
# like CDPATH, define it for your interactive shell sessions without
|
|
|
|
# exporting it.
|
|
|
|
unset CDPATH
|
|
|
|
|
2005-07-08 17:57:21 +00:00
|
|
|
die() {
|
2005-09-30 21:26:57 +00:00
|
|
|
echo >&2 "$@"
|
2005-07-08 17:57:21 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2005-12-11 09:55:49 +00:00
|
|
|
usage() {
|
|
|
|
die "Usage: $0 $USAGE"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "$LONG_USAGE" ]
|
|
|
|
then
|
|
|
|
LONG_USAGE="Usage: $0 $USAGE"
|
|
|
|
else
|
|
|
|
LONG_USAGE="Usage: $0 $USAGE
|
|
|
|
|
|
|
|
$LONG_USAGE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
2006-04-14 22:54:51 +00:00
|
|
|
-h|--h|--he|--hel|--help)
|
2005-12-11 09:55:49 +00:00
|
|
|
echo "$LONG_USAGE"
|
|
|
|
exit
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -z "$SUBDIRECTORY_OK" ]
|
|
|
|
then
|
|
|
|
: ${GIT_DIR=.git}
|
|
|
|
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
|
|
|
|
|
|
|
|
# Make sure we are in a valid repository of a vintage we understand.
|
2006-02-11 20:39:11 +00:00
|
|
|
GIT_DIR="$GIT_DIR" git repo-config --get core.nosuch >/dev/null
|
2006-02-12 21:13:12 +00:00
|
|
|
if test $? = 128
|
2006-02-11 20:39:11 +00:00
|
|
|
then
|
|
|
|
exit
|
|
|
|
fi
|
2005-12-11 09:55:49 +00:00
|
|
|
else
|
|
|
|
GIT_DIR=$(git-rev-parse --git-dir) || exit
|
|
|
|
fi
|