summaryrefslogtreecommitdiff
path: root/git-clone.sh
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2008-02-20 15:10:17 +0000
committerJunio C Hamano <gitster@pobox.com>2008-02-20 11:31:17 -0800
commit5274ba6907cc12d6e6556ff85cb0e4819bd3f730 (patch)
tree93c31367c6441ef73c63ff028c3cd59f03d09456 /git-clone.sh
parentfbd538c262b03d7b096e840a7ef0cdd54c5cea4f (diff)
downloadgit-5274ba6907cc12d6e6556ff85cb0e4819bd3f730.tar.gz
git-clone.sh: properly configure remote even if remote's head is dangling
When cloning a remote repository which's HEAD refers to a nonexistent ref, git-clone cloned all existing refs, but failed to write the configuration for 'remote'. Now it detects the dangling remote HEAD, refuses to checkout any local branch since HEAD refers to nowhere, but properly writes the configuration for 'remote', so that subsequent 'git fetch's don't fail. The problem was reported by Daniel Jacobowitz through http://bugs.debian.org/466581 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-clone.sh')
-rwxr-xr-xgit-clone.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/git-clone.sh b/git-clone.sh
index b4e858c388..0d686c3a03 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -409,11 +409,12 @@ else
cd "$D" || exit
fi
-if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
+if test -z "$bare"
then
# a non-bare repository is always in separate-remote layout
remote_top="refs/remotes/$origin"
- head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
+ head_sha1=
+ test ! -r "$GIT_DIR/REMOTE_HEAD" || head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
case "$head_sha1" in
'ref: refs/'*)
# Uh-oh, the remote told us (http transport done against
@@ -470,9 +471,16 @@ then
git config branch."$head_points_at".merge "refs/heads/$head_points_at"
;;
'')
- # Source had detached HEAD pointing nowhere
- git update-ref --no-deref HEAD "$head_sha1" &&
- rm -f "refs/remotes/$origin/HEAD"
+ 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
;;
esac