2005-07-09 01:57:21 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-11-24 16:12:11 +08: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-09 01:57:21 +08:00
|
|
|
|
2005-09-13 10:47:07 +08: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-09 01:57:21 +08:00
|
|
|
die() {
|
2005-10-01 05:26:57 +08:00
|
|
|
echo >&2 "$@"
|
2005-07-09 01:57:21 +08:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2005-12-11 17:55:49 +08: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-15 06:54:51 +08:00
|
|
|
-h|--h|--he|--hel|--help)
|
2005-12-11 17:55:49 +08:00
|
|
|
echo "$LONG_USAGE"
|
|
|
|
exit
|
|
|
|
esac
|
|
|
|
|
2006-08-12 09:47:50 +08:00
|
|
|
# Make sure we are in a valid repository of a vintage we understand.
|
2005-12-11 17:55:49 +08:00
|
|
|
if [ -z "$SUBDIRECTORY_OK" ]
|
|
|
|
then
|
|
|
|
: ${GIT_DIR=.git}
|
2006-08-12 09:47:50 +08:00
|
|
|
GIT_DIR=$(GIT_DIR="$GIT_DIR" git-rev-parse --git-dir) || exit
|
2005-12-11 17:55:49 +08:00
|
|
|
else
|
|
|
|
GIT_DIR=$(git-rev-parse --git-dir) || exit
|
|
|
|
fi
|
2006-08-12 09:47:50 +08:00
|
|
|
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
|