You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
526 lines
12 KiB
526 lines
12 KiB
20 years ago
|
#!/bin/sh
|
||
20 years ago
|
#
|
||
|
# Copyright (c) 2005, Linus Torvalds
|
||
|
# Copyright (c) 2005, Junio C Hamano
|
||
18 years ago
|
#
|
||
20 years ago
|
# Clone a repository into a different directory that does not yet exist.
|
||
|
|
||
20 years ago
|
# See git-sh-setup why.
|
||
|
unset CDPATH
|
||
|
|
||
17 years ago
|
OPTIONS_SPEC="\
|
||
|
git-clone [options] [--] <repo> [<dir>]
|
||
|
--
|
||
|
n,no-checkout don't create a checkout
|
||
|
bare create a bare repository
|
||
|
naked create a bare repository
|
||
|
l,local to clone from a local repository
|
||
|
no-hardlinks don't use local hardlinks, always copy
|
||
|
s,shared setup as a shared repository
|
||
|
template= path to the template directory
|
||
|
q,quiet be quiet
|
||
|
reference= reference repository
|
||
|
o,origin= use <name> instead of 'origin' to track upstream
|
||
|
u,upload-pack= path to git-upload-pack on the remote
|
||
|
depth= create a shallow clone of that depth
|
||
|
|
||
|
use-separate-remote compatibility, do not use
|
||
|
no-separate-remote compatibility, do not use"
|
||
|
|
||
18 years ago
|
die() {
|
||
|
echo >&2 "$@"
|
||
20 years ago
|
exit 1
|
||
|
}
|
||
|
|
||
18 years ago
|
usage() {
|
||
17 years ago
|
exec "$0" -h
|
||
18 years ago
|
}
|
||
|
|
||
17 years ago
|
eval "$(echo "$OPTIONS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
|
||
17 years ago
|
|
||
20 years ago
|
get_repo_base() {
|
||
18 years ago
|
(
|
||
|
cd "`/bin/pwd`" &&
|
||
18 years ago
|
cd "$1" || cd "$1.git" &&
|
||
18 years ago
|
{
|
||
18 years ago
|
cd .git
|
||
18 years ago
|
pwd
|
||
|
}
|
||
18 years ago
|
) 2>/dev/null
|
||
20 years ago
|
}
|
||
|
|
||
17 years ago
|
if [ -n "$GIT_SSL_NO_VERIFY" -o \
|
||
|
"`git config --bool http.sslVerify`" = false ]; then
|
||
20 years ago
|
curl_extra_args="-k"
|
||
|
fi
|
||
|
|
||
|
http_fetch () {
|
||
|
# $1 = Remote, $2 = Local
|
||
17 years ago
|
curl -nsfL $curl_extra_args "$1" >"$2"
|
||
|
curl_exit_status=$?
|
||
|
case $curl_exit_status in
|
||
|
126|127) exit ;;
|
||
|
*) return $curl_exit_status ;;
|
||
|
esac
|
||
20 years ago
|
}
|
||
|
|
||
|
clone_dumb_http () {
|
||
|
# $1 - remote, $2 - local
|
||
|
cd "$2" &&
|
||
19 years ago
|
clone_tmp="$GIT_DIR/clone-tmp" &&
|
||
20 years ago
|
mkdir -p "$clone_tmp" || exit 1
|
||
19 years ago
|
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
|
||
18 years ago
|
"`git config --bool http.noEPSV`" = true ]; then
|
||
19 years ago
|
curl_extra_args="${curl_extra_args} --disable-epsv"
|
||
|
fi
|
||
18 years ago
|
http_fetch "$1/info/refs" "$clone_tmp/refs" ||
|
||
|
die "Cannot get remote repository information.
|
||
20 years ago
|
Perhaps git-update-server-info needs to be run there?"
|
||
18 years ago
|
test "z$quiet" = z && v=-v || v=
|
||
20 years ago
|
while read sha1 refname
|
||
|
do
|
||
19 years ago
|
name=`expr "z$refname" : 'zrefs/\(.*\)'` &&
|
||
19 years ago
|
case "$name" in
|
||
19 years ago
|
*^*) continue;;
|
||
19 years ago
|
esac
|
||
18 years ago
|
case "$bare,$name" in
|
||
|
yes,* | ,heads/* | ,tags/*) ;;
|
||
|
*) continue ;;
|
||
|
esac
|
||
19 years ago
|
if test -n "$use_separate_remote" &&
|
||
19 years ago
|
branch_name=`expr "z$name" : 'zheads/\(.*\)'`
|
||
19 years ago
|
then
|
||
19 years ago
|
tname="remotes/$origin/$branch_name"
|
||
19 years ago
|
else
|
||
|
tname=$name
|
||
|
fi
|
||
18 years ago
|
git-http-fetch $v -a -w "$tname" "$sha1" "$1" || exit 1
|
||
20 years ago
|
done <"$clone_tmp/refs"
|
||
|
rm -fr "$clone_tmp"
|
||
19 years ago
|
http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
|
||
|
rm -f "$GIT_DIR/REMOTE_HEAD"
|
||
18 years ago
|
if test -f "$GIT_DIR/REMOTE_HEAD"; then
|
||
|
head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
|
||
|
case "$head_sha1" in
|
||
|
'ref: refs/'*)
|
||
|
;;
|
||
|
*)
|
||
|
git-http-fetch $v -a "$head_sha1" "$1" ||
|
||
|
rm -f "$GIT_DIR/REMOTE_HEAD"
|
||
|
;;
|
||
|
esac
|
||
|
fi
|
||
19 years ago
|
}
|
||
|
|
||
20 years ago
|
quiet=
|
||
19 years ago
|
local=no
|
||
18 years ago
|
use_local_hardlink=yes
|
||
20 years ago
|
local_shared=no
|
||
19 years ago
|
unset template
|
||
20 years ago
|
no_checkout=
|
||
20 years ago
|
upload_pack=
|
||
19 years ago
|
bare=
|
||
19 years ago
|
reference=
|
||
|
origin=
|
||
19 years ago
|
origin_override=
|
||
18 years ago
|
use_separate_remote=t
|
||
18 years ago
|
depth=
|
||
18 years ago
|
no_progress=
|
||
18 years ago
|
local_explicitly_asked_for=
|
||
18 years ago
|
test -t 1 || no_progress=--no-progress
|
||
17 years ago
|
|
||
|
while test $# != 0
|
||
|
do
|
||
|
case "$1" in
|
||
|
-n|--no-checkout)
|
||
|
no_checkout=yes ;;
|
||
|
--naked|--bare)
|
||
|
bare=yes ;;
|
||
|
-l|--local)
|
||
|
local_explicitly_asked_for=yes
|
||
|
use_local_hardlink=yes
|
||
|
;;
|
||
|
--no-hardlinks)
|
||
|
use_local_hardlink=no ;;
|
||
|
-s|--shared)
|
||
|
local_shared=yes ;;
|
||
|
--template)
|
||
19 years ago
|
shift; template="--template=$1" ;;
|
||
17 years ago
|
-q|--quiet)
|
||
|
quiet=-q ;;
|
||
|
--use-separate-remote|--no-separate-remote)
|
||
18 years ago
|
die "clones are always made with separate-remote layout" ;;
|
||
17 years ago
|
--reference)
|
||
19 years ago
|
shift; reference="$1" ;;
|
||
17 years ago
|
-o|--origin)
|
||
17 years ago
|
shift;
|
||
|
case "$1" in
|
||
19 years ago
|
'')
|
||
|
usage ;;
|
||
19 years ago
|
*/*)
|
||
17 years ago
|
die "'$1' is not suitable for an origin name"
|
||
19 years ago
|
esac
|
||
17 years ago
|
git check-ref-format "heads/$1" ||
|
||
|
die "'$1' is not suitable for a branch name"
|
||
18 years ago
|
test -z "$origin_override" ||
|
||
|
die "Do not give more than one --origin options."
|
||
19 years ago
|
origin_override=yes
|
||
17 years ago
|
origin="$1"
|
||
19 years ago
|
;;
|
||
17 years ago
|
-u|--upload-pack)
|
||
20 years ago
|
shift
|
||
18 years ago
|
upload_pack="--upload-pack=$1" ;;
|
||
17 years ago
|
--depth)
|
||
18 years ago
|
shift
|
||
17 years ago
|
depth="--depth=$1" ;;
|
||
|
--)
|
||
17 years ago
|
shift
|
||
|
break ;;
|
||
17 years ago
|
*)
|
||
|
usage ;;
|
||
20 years ago
|
esac
|
||
|
shift
|
||
|
done
|
||
|
|
||
19 years ago
|
repo="$1"
|
||
18 years ago
|
test -n "$repo" ||
|
||
|
die 'you must specify a repository to clone.'
|
||
19 years ago
|
|
||
18 years ago
|
# --bare implies --no-checkout and --no-separate-remote
|
||
19 years ago
|
if test yes = "$bare"
|
||
|
then
|
||
|
if test yes = "$origin_override"
|
||
|
then
|
||
18 years ago
|
die '--bare and --origin $origin options are incompatible.'
|
||
19 years ago
|
fi
|
||
|
no_checkout=yes
|
||
18 years ago
|
use_separate_remote=
|
||
19 years ago
|
fi
|
||
19 years ago
|
|
||
19 years ago
|
if test -z "$origin"
|
||
19 years ago
|
then
|
||
19 years ago
|
origin=origin
|
||
19 years ago
|
fi
|
||
|
|
||
20 years ago
|
# Turn the source into an absolute path if
|
||
|
# it is local
|
||
|
if base=$(get_repo_base "$repo"); then
|
||
|
repo="$base"
|
||
17 years ago
|
if test -z "$depth"
|
||
|
then
|
||
|
local=yes
|
||
|
fi
|
||
17 years ago
|
elif test -f "$repo"
|
||
|
then
|
||
|
case "$repo" in /*) ;; *) repo="$PWD/$repo" ;; esac
|
||
|
fi
|
||
|
|
||
|
# Decide the directory name of the new repository
|
||
|
if test -n "$2"
|
||
|
then
|
||
|
dir="$2"
|
||
17 years ago
|
test $# = 2 || die "excess parameter to git-clone"
|
||
17 years ago
|
else
|
||
|
# Derive one from the repository name
|
||
|
# Try using "humanish" part of source repo if user didn't specify one
|
||
|
if test -f "$repo"
|
||
|
then
|
||
|
# Cloning from a bundle
|
||
|
dir=$(echo "$repo" | sed -e 's|/*\.bundle$||' -e 's|.*/||g')
|
||
|
else
|
||
|
dir=$(echo "$repo" |
|
||
|
sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
|
||
|
fi
|
||
20 years ago
|
fi
|
||
|
|
||
18 years ago
|
[ -e "$dir" ] && die "destination directory '$dir' already exists."
|
||
18 years ago
|
[ yes = "$bare" ] && unset GIT_WORK_TREE
|
||
|
[ -n "$GIT_WORK_TREE" ] && [ -e "$GIT_WORK_TREE" ] &&
|
||
|
die "working tree '$GIT_WORK_TREE' already exists."
|
||
18 years ago
|
D=
|
||
18 years ago
|
W=
|
||
18 years ago
|
cleanup() {
|
||
|
test -z "$D" && rm -rf "$dir"
|
||
18 years ago
|
test -z "$W" && test -n "$GIT_WORK_TREE" && rm -rf "$GIT_WORK_TREE"
|
||
18 years ago
|
cd ..
|
||
|
test -n "$D" && rm -rf "$D"
|
||
18 years ago
|
test -n "$W" && rm -rf "$W"
|
||
18 years ago
|
exit $err
|
||
|
}
|
||
17 years ago
|
trap 'err=$?; cleanup' 0
|
||
18 years ago
|
mkdir -p "$dir" && D=$(cd "$dir" && pwd) || usage
|
||
18 years ago
|
test -n "$GIT_WORK_TREE" && mkdir -p "$GIT_WORK_TREE" &&
|
||
17 years ago
|
W=$(cd "$GIT_WORK_TREE" && pwd) && GIT_WORK_TREE="$W" && export GIT_WORK_TREE
|
||
18 years ago
|
if test yes = "$bare" || test -n "$GIT_WORK_TREE"; then
|
||
|
GIT_DIR="$D"
|
||
|
else
|
||
|
GIT_DIR="$D/.git"
|
||
|
fi &&
|
||
18 years ago
|
export GIT_DIR &&
|
||
18 years ago
|
GIT_CONFIG="$GIT_DIR/config" git-init $quiet ${template+"$template"} || usage
|
||
|
|
||
|
if test -n "$bare"
|
||
|
then
|
||
|
GIT_CONFIG="$GIT_DIR/config" git config core.bare true
|
||
|
fi
|
||
20 years ago
|
|
||
19 years ago
|
if test -n "$reference"
|
||
|
then
|
||
18 years ago
|
ref_git=
|
||
19 years ago
|
if test -d "$reference"
|
||
|
then
|
||
|
if test -d "$reference/.git/objects"
|
||
|
then
|
||
18 years ago
|
ref_git="$reference/.git"
|
||
|
elif test -d "$reference/objects"
|
||
|
then
|
||
|
ref_git="$reference"
|
||
19 years ago
|
fi
|
||
18 years ago
|
fi
|
||
|
if test -n "$ref_git"
|
||
|
then
|
||
|
ref_git=$(cd "$ref_git" && pwd)
|
||
|
echo "$ref_git/objects" >"$GIT_DIR/objects/info/alternates"
|
||
|
(
|
||
|
GIT_DIR="$ref_git" git for-each-ref \
|
||
|
--format='%(objectname) %(*objectname)'
|
||
|
) |
|
||
|
while read a b
|
||
|
do
|
||
|
test -z "$a" ||
|
||
|
git update-ref "refs/reference-tmp/$a" "$a"
|
||
|
test -z "$b" ||
|
||
|
git update-ref "refs/reference-tmp/$b" "$b"
|
||
|
done
|
||
19 years ago
|
else
|
||
18 years ago
|
die "reference repository '$reference' is not a local directory."
|
||
19 years ago
|
fi
|
||
|
fi
|
||
|
|
||
|
rm -f "$GIT_DIR/CLONE_HEAD"
|
||
|
|
||
20 years ago
|
# We do local magic only when the user tells us to.
|
||
18 years ago
|
case "$local" in
|
||
|
yes)
|
||
18 years ago
|
( cd "$repo/objects" ) ||
|
||
18 years ago
|
die "cannot chdir to local '$repo/objects'."
|
||
20 years ago
|
|
||
18 years ago
|
if test "$local_shared" = yes
|
||
|
then
|
||
|
mkdir -p "$GIT_DIR/objects/info"
|
||
|
echo "$repo/objects" >>"$GIT_DIR/objects/info/alternates"
|
||
|
else
|
||
17 years ago
|
cpio_quiet_flag=""
|
||
|
cpio --help 2>&1 | grep -- --quiet >/dev/null && \
|
||
|
cpio_quiet_flag=--quiet
|
||
18 years ago
|
l= &&
|
||
|
if test "$use_local_hardlink" = yes
|
||
|
then
|
||
|
# See if we can hardlink and drop "l" if not.
|
||
|
sample_file=$(cd "$repo" && \
|
||
|
find objects -type f -print | sed -e 1q)
|
||
|
# objects directory should not be empty because
|
||
|
# we are cloning!
|
||
17 years ago
|
test -f "$repo/$sample_file" ||
|
||
|
die "fatal: cannot clone empty repository"
|
||
18 years ago
|
if ln "$repo/$sample_file" "$GIT_DIR/objects/sample" 2>/dev/null
|
||
|
then
|
||
|
rm -f "$GIT_DIR/objects/sample"
|
||
|
l=l
|
||
18 years ago
|
elif test -n "$local_explicitly_asked_for"
|
||
|
then
|
||
18 years ago
|
echo >&2 "Warning: -l asked but cannot hardlink to $repo"
|
||
|
fi
|
||
|
fi &&
|
||
|
cd "$repo" &&
|
||
17 years ago
|
# Create dirs using umask and permissions and destination
|
||
|
find objects -type d -print | (cd "$GIT_DIR" && xargs mkdir -p) &&
|
||
|
# Copy existing 0444 permissions on content
|
||
|
find objects ! -type d -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \
|
||
17 years ago
|
exit 1
|
||
18 years ago
|
fi
|
||
19 years ago
|
git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
|
||
20 years ago
|
;;
|
||
|
*)
|
||
20 years ago
|
case "$repo" in
|
||
|
rsync://*)
|
||
18 years ago
|
case "$depth" in
|
||
|
"") ;;
|
||
|
*) die "shallow over rsync not supported" ;;
|
||
|
esac
|
||
20 years ago
|
rsync $quiet -av --ignore-existing \
|
||
19 years ago
|
--exclude info "$repo/objects/" "$GIT_DIR/objects/" ||
|
||
|
exit
|
||
20 years ago
|
# Look at objects/info/alternates for rsync -- http will
|
||
|
# support it natively and git native ones will do it on the
|
||
|
# remote end. Not having that file is not a crime.
|
||
20 years ago
|
rsync -q "$repo/objects/info/alternates" \
|
||
19 years ago
|
"$GIT_DIR/TMP_ALT" 2>/dev/null ||
|
||
|
rm -f "$GIT_DIR/TMP_ALT"
|
||
|
if test -f "$GIT_DIR/TMP_ALT"
|
||
20 years ago
|
then
|
||
19 years ago
|
( cd "$D" &&
|
||
20 years ago
|
. git-parse-remote &&
|
||
19 years ago
|
resolve_alternates "$repo" <"$GIT_DIR/TMP_ALT" ) |
|
||
20 years ago
|
while read alt
|
||
|
do
|
||
|
case "$alt" in 'bad alternate: '*) die "$alt";; esac
|
||
|
case "$quiet" in
|
||
|
'') echo >&2 "Getting alternate: $alt" ;;
|
||
|
esac
|
||
|
rsync $quiet -av --ignore-existing \
|
||
19 years ago
|
--exclude info "$alt" "$GIT_DIR/objects" || exit
|
||
20 years ago
|
done
|
||
19 years ago
|
rm -f "$GIT_DIR/TMP_ALT"
|
||
20 years ago
|
fi
|
||
19 years ago
|
git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
|
||
20 years ago
|
;;
|
||
19 years ago
|
https://*|http://*|ftp://*)
|
||
18 years ago
|
case "$depth" in
|
||
|
"") ;;
|
||
|
*) die "shallow over http or ftp not supported" ;;
|
||
|
esac
|
||
19 years ago
|
if test -z "@@NO_CURL@@"
|
||
|
then
|
||
|
clone_dumb_http "$repo" "$D"
|
||
|
else
|
||
18 years ago
|
die "http transport not supported, rebuild Git with curl support"
|
||
19 years ago
|
fi
|
||
20 years ago
|
;;
|
||
|
*)
|
||
17 years ago
|
if [ -f "$repo" ] ; then
|
||
|
git bundle unbundle "$repo" > "$GIT_DIR/CLONE_HEAD" ||
|
||
|
die "unbundle from '$repo' failed."
|
||
|
else
|
||
|
case "$upload_pack" in
|
||
|
'') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";;
|
||
|
*) git-fetch-pack --all -k \
|
||
|
$quiet "$upload_pack" $depth $no_progress "$repo" ;;
|
||
|
esac >"$GIT_DIR/CLONE_HEAD" ||
|
||
18 years ago
|
die "fetch-pack from '$repo' failed."
|
||
17 years ago
|
fi
|
||
20 years ago
|
;;
|
||
20 years ago
|
esac
|
||
20 years ago
|
;;
|
||
|
esac
|
||
19 years ago
|
test -d "$GIT_DIR/refs/reference-tmp" && rm -fr "$GIT_DIR/refs/reference-tmp"
|
||
|
|
||
|
if test -f "$GIT_DIR/CLONE_HEAD"
|
||
|
then
|
||
19 years ago
|
# Read git-fetch-pack -k output and store the remote branches.
|
||
18 years ago
|
if [ -n "$use_separate_remote" ]
|
||
|
then
|
||
|
branch_top="remotes/$origin"
|
||
|
else
|
||
|
branch_top="heads"
|
||
|
fi
|
||
|
tag_top="tags"
|
||
|
while read sha1 name
|
||
|
do
|
||
|
case "$name" in
|
||
|
*'^{}')
|
||
|
continue ;;
|
||
|
HEAD)
|
||
|
destname="REMOTE_HEAD" ;;
|
||
|
refs/heads/*)
|
||
|
destname="refs/$branch_top/${name#refs/heads/}" ;;
|
||
|
refs/tags/*)
|
||
|
destname="refs/$tag_top/${name#refs/tags/}" ;;
|
||
|
*)
|
||
|
continue ;;
|
||
|
esac
|
||
18 years ago
|
git update-ref -m "clone: from $repo" "$destname" "$sha1" ""
|
||
18 years ago
|
done < "$GIT_DIR/CLONE_HEAD"
|
||
19 years ago
|
fi
|
||
20 years ago
|
|
||
18 years ago
|
if test -n "$W"; then
|
||
|
cd "$W" || exit
|
||
|
else
|
||
|
cd "$D" || exit
|
||
|
fi
|
||
20 years ago
|
|
||
17 years ago
|
if test -z "$bare"
|
||
20 years ago
|
then
|
||
18 years ago
|
# a non-bare repository is always in separate-remote layout
|
||
|
remote_top="refs/remotes/$origin"
|
||
17 years ago
|
head_sha1=
|
||
|
test ! -r "$GIT_DIR/REMOTE_HEAD" || head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
|
||
19 years ago
|
case "$head_sha1" in
|
||
|
'ref: refs/'*)
|
||
|
# Uh-oh, the remote told us (http transport done against
|
||
|
# new style repository with a symref HEAD).
|
||
|
# Ideally we should skip the guesswork but for now
|
||
|
# opt for minimum change.
|
||
19 years ago
|
head_sha1=`expr "z$head_sha1" : 'zref: refs/heads/\(.*\)'`
|
||
19 years ago
|
head_sha1=`cat "$GIT_DIR/$remote_top/$head_sha1"`
|
||
|
;;
|
||
|
esac
|
||
19 years ago
|
|
||
19 years ago
|
# The name under $remote_top the remote HEAD seems to point at.
|
||
19 years ago
|
head_points_at=$(
|
||
|
(
|
||
18 years ago
|
test -f "$GIT_DIR/$remote_top/master" && echo "master"
|
||
19 years ago
|
cd "$GIT_DIR/$remote_top" &&
|
||
|
find . -type f -print | sed -e 's/^\.\///'
|
||
|
) | (
|
||
|
done=f
|
||
|
while read name
|
||
|
do
|
||
|
test t = $done && continue
|
||
|
branch_tip=`cat "$GIT_DIR/$remote_top/$name"`
|
||
|
if test "$head_sha1" = "$branch_tip"
|
||
|
then
|
||
|
echo "$name"
|
||
|
done=t
|
||
|
fi
|
||
|
done
|
||
|
)
|
||
|
)
|
||
19 years ago
|
|
||
18 years ago
|
# Upstream URL
|
||
18 years ago
|
git config remote."$origin".url "$repo" &&
|
||
18 years ago
|
|
||
|
# Set up the mappings to track the remote branches.
|
||
18 years ago
|
git config remote."$origin".fetch \
|
||
18 years ago
|
"+refs/heads/*:$remote_top/*" '^$' &&
|
||
|
|
||
18 years ago
|
# Write out remote.$origin config, and update our "$head_points_at".
|
||
19 years ago
|
case "$head_points_at" in
|
||
19 years ago
|
?*)
|
||
18 years ago
|
# Local default branch
|
||
18 years ago
|
git symbolic-ref HEAD "refs/heads/$head_points_at" &&
|
||
18 years ago
|
|
||
|
# Tracking branch for the primary branch at the remote.
|
||
18 years ago
|
git update-ref HEAD "$head_sha1" &&
|
||
18 years ago
|
|
||
18 years ago
|
rm -f "refs/remotes/$origin/HEAD"
|
||
18 years ago
|
git symbolic-ref "refs/remotes/$origin/HEAD" \
|
||
18 years ago
|
"refs/remotes/$origin/$head_points_at" &&
|
||
18 years ago
|
|
||
18 years ago
|
git config branch."$head_points_at".remote "$origin" &&
|
||
|
git config branch."$head_points_at".merge "refs/heads/$head_points_at"
|
||
18 years ago
|
;;
|
||
|
'')
|
||
17 years ago
|
if test -z "$head_sha1"
|
||
|
then
|
||
|
# Source had nonexistent ref in HEAD
|
||
|
echo >&2 "Warning: Remote HEAD refers to nonexistent ref, unable to checkout."
|
||
|
no_checkout=t
|
||
|
else
|
||
|
# Source had detached HEAD pointing nowhere
|
||
|
git update-ref --no-deref HEAD "$head_sha1" &&
|
||
|
rm -f "refs/remotes/$origin/HEAD"
|
||
|
fi
|
||
18 years ago
|
;;
|
||
19 years ago
|
esac
|
||
|
|
||
20 years ago
|
case "$no_checkout" in
|
||
|
'')
|
||
18 years ago
|
test "z$quiet" = z -a "z$no_progress" = z && v=-v || v=
|
||
18 years ago
|
git read-tree -m -u $v HEAD HEAD
|
||
20 years ago
|
esac
|
||
|
fi
|
||
19 years ago
|
rm -f "$GIT_DIR/CLONE_HEAD" "$GIT_DIR/REMOTE_HEAD"
|
||
19 years ago
|
|
||
19 years ago
|
trap - 0
|