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>
This commit is contained in:
parent
69bcc43eca
commit
093b068891
12
git-fetch.sh
12
git-fetch.sh
@ -270,12 +270,20 @@ fetch_main () {
|
|||||||
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
|
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
|
||||||
curl_extra_args="-k"
|
curl_extra_args="-k"
|
||||||
fi
|
fi
|
||||||
|
max_depth=5
|
||||||
|
depth=0
|
||||||
|
head="ref: $remote_name"
|
||||||
|
while (expr "z$head" : "zref:" && expr $depth \< $max_depth) >/dev/null
|
||||||
|
do
|
||||||
remote_name_quoted=$(perl -e '
|
remote_name_quoted=$(perl -e '
|
||||||
my $u = $ARGV[0];
|
my $u = $ARGV[0];
|
||||||
|
$u =~ s/^ref:\s*//;
|
||||||
$u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
|
$u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
|
||||||
print "$u";
|
print "$u";
|
||||||
' "$remote_name")
|
' "$head")
|
||||||
head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted") &&
|
head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted")
|
||||||
|
depth=$( expr \( $depth + 1 \) )
|
||||||
|
done
|
||||||
expr "z$head" : "z$_x40\$" >/dev/null ||
|
expr "z$head" : "z$_x40\$" >/dev/null ||
|
||||||
die "Failed to fetch $remote_name from $remote"
|
die "Failed to fetch $remote_name from $remote"
|
||||||
echo >&2 Fetching "$remote_name from $remote" using http
|
echo >&2 Fetching "$remote_name from $remote" using http
|
||||||
|
Loading…
Reference in New Issue
Block a user