git-fetch: resolve remote symrefs for HTTP transport
git-fetch validates that a remote ref resolves to a SHA1 prior to calling git-http-fetch. This adds support for resolving a few levels of symrefs to get to the SHA1. Signed-off-by: Nick Hengeveld <nickh@reactrix.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Nick Hengeveld committed
Apr 26, 2006 at 09:10 UTC
093b06889104d218e95251176af5cf4aa5dd5cdd
1 file changed
+12
-4
git-fetch.sh
+12
-4
@@ -270,14 +270,22 @@ fetch_main () {
270
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
271
curl_extra_args="-k"
272
fi
273
- remote_name_quoted=$(perl -e '
273
+ max_depth=5
274
+ depth=0
275
+ head="ref: $remote_name"
276
+ while (expr "z$head" : "zref:" && expr $depth \< $max_depth) >/dev/null
277
+ do
278
+ remote_name_quoted=$(perl -e '
279
my $u = $ARGV[0];
280
+ $u =~ s/^ref:\s*//;
281
$u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
282
print "$u";
277
- ' "$remote_name")
278
- head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted") &&
283
+ ' "$head")
284
+ head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted")
285
+ depth=$( expr \( $depth + 1 \) )
286
+ done
287
expr "z$head" : "z$_x40\$" >/dev/null ||
280
- die "Failed to fetch $remote_name from $remote"
288
+ die "Failed to fetch $remote_name from $remote"
289
echo >&2 Fetching "$remote_name from $remote" using http
290
git-http-fetch -v -a "$head" "$remote/" || exit
291
;;