[PATCH] git-clone: Better handling of failed fetches of HEAD over HTTP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---
 git-clone.sh |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]