git-fetch --tags: deal with tags with spaces in them.
"git-fetch --tags" can get confused with tags with spaces in their names, it used to use shell IFS to split the list of tags and also used curl which insists the URL to be escaped. Fix it so it can work with Martin's moodle repository http://locke.catalyst.net.nz/git/moodle.git/. We still reserve characters like leading plus-sign '+' and colon ':' anywhere to represent refspec src-dst pair, and obviously we cannot use LF (that terminates Pull: line in .git/remotes files), but now you can have spaces with this patch. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Oct 10, 2005 at 23:22 UTC
221e743c037fc1f9a729adc760546d23df9544a7
1 file changed
+18
-5
git-fetch.sh
+18
-5
@@ -5,6 +5,10 @@
5
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
6
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
7
8
+LF='
9
+'
10
+IFS="$LF"
11
+
12
tags=
13
append=
14
force=
@@ -170,11 +174,14 @@ esac
174
reflist=$(get_remote_refs_for_fetch "$@")
175
if test "$tags"
176
then
173
- taglist=$(git-ls-remote --tags "$remote" | awk '{ print "."$2":"$2 }')
177
+ taglist=$(git-ls-remote --tags "$remote" |
178
+ sed -e '
179
+ s/^[^ ]* //
180
+ s/.*/&:&/')
181
if test "$#" -gt 1
182
then
183
# remote URL plus explicit refspecs; we need to merge them.
177
- reflist="$reflist $taglist"
184
+ reflist="$reflist$LF$taglist"
185
else
186
# No explicit refspecs; fetch tags only.
187
reflist=$taglist
@@ -183,7 +190,7 @@ fi
190
191
for ref in $reflist
192
do
186
- refs="$refs $ref"
193
+ refs="$refs$LF$ref"
194
195
# These are relative path from $GIT_DIR, typically starting at refs/
196
# but may be HEAD
@@ -204,7 +211,7 @@ do
211
remote_name=$(expr "$ref" : '\([^:]*\):')
212
local_name=$(expr "$ref" : '[^:]*:\(.*\)')
213
207
- rref="$rref $remote_name"
214
+ rref="$rref$LF$remote_name"
215
216
# There are transports that can fetch only one head at a time...
217
case "$remote" in
@@ -212,7 +219,12 @@ do
219
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
220
curl_extra_args="-k"
221
fi
215
- head=$(curl -nsf $curl_extra_args "$remote/$remote_name") &&
222
+ remote_name_quoted=$(perl -e '
223
+ my $u = $ARGV[0];
224
+ $u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
225
+ print "$u";
226
+ ' "$remote_name")
227
+ head=$(curl -nsf $curl_extra_args "$remote/$remote_name_quoted") &&
228
expr "$head" : "$_x40\$" >/dev/null ||
229
die "Failed to fetch $remote_name from $remote"
230
echo >&2 Fetching "$remote_name from $remote" using http
@@ -262,6 +274,7 @@ case "$remote" in
274
http://* | https://* | rsync://* )
275
;; # we are already done.
276
*)
277
+ IFS=" $LF"
278
(
279
git-fetch-pack "$remote" $rref || echo failed "$remote"
280
) |