Junio said:
> Why not default to 'master' (if found) and issue a warning?
A common problem when cloning over http is that the repo has a symlink for HEAD, and apache refuses to serve symlinks by default.
With this patch, the clone will fallback to trying to get refs/heads/master -- which often works. If it cannot get HEAD or refs/heads/master, then it will die, aborting the clone.
Signed-off-by: Martin Langhoff <martin@catalyst.net.nz> --- git-clone.sh | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
Show changes to git-clone.sh +8 −1
diff --git a/git-clone.sh b/git-clone.sh index 513b574..e98e064 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -64,7 +64,14 @@ Perhaps git-update-server-info needs to be run there?" done <"$clone_tmp/refs" rm -fr "$clone_tmp" http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" || - rm -f "$GIT_DIR/REMOTE_HEAD" + (echo "Could not get "$1/HEAD", perhaps it is a symlink: trying with refs/heads/master" && + http_fetch "$1/refs/heads/master" "$GIT_DIR/REMOTE_HEAD") || + rm -f "$GIT_DIR/REMOTE_HEAD" + + if test ! -f "$GIT_DIR/REMOTE_HEAD" + then + die "Could not retrieve $1/HEAD nor $1/refs/heads/master ." + fi } quiet=
-- 1.5.1.106.ga32037