Skip to content

Commit 2986c02

Browse files
author
Junio C Hamano
committed
git-fetch: fix dumb protocol transport to fetch from pack-pruned ref
Earlier, commit walkers downloaded loose refs from refs/ hierarchy of the remote side to find where to start walking; this would not work for a repository whose refs are packed and then pruned. With the previous change, we have ls-remote output from the remote in-core; we can use the value from there without requiring loose refs anymore. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28b8e61 commit 2986c02

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

git-fetch.sh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -307,22 +307,20 @@ fetch_main () {
307307
"`git-repo-config --bool http.noEPSV`" = true ]; then
308308
noepsv_opt="--disable-epsv"
309309
fi
310-
max_depth=5
311-
depth=0
312-
head="ref: $remote_name"
313-
while (expr "z$head" : "zref:" && expr $depth \< $max_depth) >/dev/null
314-
do
315-
remote_name_quoted=$(@@PERL@@ -e '
316-
my $u = $ARGV[0];
317-
$u =~ s/^ref:\s*//;
318-
$u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
319-
print "$u";
320-
' "$head")
321-
head=$(curl -nsfL $curl_extra_args $noepsv_opt "$remote/$remote_name_quoted")
322-
depth=$( expr \( $depth + 1 \) )
323-
done
310+
311+
# Find $remote_name from ls-remote output.
312+
head=$(
313+
IFS=' '
314+
echo "$ls_remote_result" |
315+
while read sha1 name
316+
do
317+
test "z$name" = "z$remote_name" || continue
318+
echo "$sha1"
319+
break
320+
done
321+
)
324322
expr "z$head" : "z$_x40\$" >/dev/null ||
325-
die "Failed to fetch $remote_name from $remote"
323+
die "No such ref $remote_name at $remote"
326324
echo >&2 "Fetching $remote_name from $remote using $proto"
327325
git-http-fetch -v -a "$head" "$remote/" || exit
328326
;;

0 commit comments

Comments
 (0)