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 <junkio@cox.net>
Junio C Hamano committed
Nov 22, 2006 at 22:24 UTC
2986c02217f98809d8990e7679edf0f5d99f904d
1 file changed
+13
-15
git-fetch.sh
+13
-15
@@ -307,22 +307,20 @@ fetch_main () {
307
"`git-repo-config --bool http.noEPSV`" = true ]; then
308
noepsv_opt="--disable-epsv"
309
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
+ )
322
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"
324
echo >&2 "Fetching $remote_name from $remote using $proto"
325
git-http-fetch -v -a "$head" "$remote/" || exit
326
;;