git/git-sh-setup.sh
Junio C Hamano 4b441f47ce git-fetch: allow updating the current branch in a bare repository.
Sometimes, people have only fetch access into a bare repository
that is used as a back-up location (or a distribution point) but
does not have a push access for networking reasons, e.g. one end
being behind a firewall, and updating the "current branch" in
such a case is perfectly fine.

This allows such a fetch without --update-head-ok, which is a
flag that should never be used by end users otherwise.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-07 21:36:35 -08:00

63 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
#
# 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.
# 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
die() {
echo >&2 "$@"
exit 1
}
usage() {
die "Usage: $0 $USAGE"
}
set_reflog_action() {
if [ -z "${GIT_REFLOG_ACTION:+set}" ]
then
GIT_REFLOG_ACTION="$*"
export GIT_REFLOG_ACTION
fi
}
is_bare_repository () {
git-repo-config --bool --get core.bare ||
case "$GIT_DIR" in
.git | */.git) echo false ;;
*) echo true ;;
esac
}
if [ -z "$LONG_USAGE" ]
then
LONG_USAGE="Usage: $0 $USAGE"
else
LONG_USAGE="Usage: $0 $USAGE
$LONG_USAGE"
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "$LONG_USAGE"
exit
esac
# Make sure we are in a valid repository of a vintage we understand.
if [ -z "$SUBDIRECTORY_OK" ]
then
: ${GIT_DIR=.git}
GIT_DIR=$(GIT_DIR="$GIT_DIR" git-rev-parse --git-dir) || exit
else
GIT_DIR=$(git-rev-parse --git-dir) || exit
fi
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}