git-fetch --tags: reject malformed tags.
When the other end was prepared with older git and has tags that do not follow the naming convention (see check-ref-format), do not barf but simply reject to copy them. Initial fix by Simon Richter, but done differently. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 5, 2006 at 19:42 UTC
81214e4ddf2f0114ce7756a014dc533340fcb3f9
1 file changed
+14
-5
git-fetch.sh
+14
-5
@@ -188,11 +188,20 @@ esac
188
reflist=$(get_remote_refs_for_fetch "$@")
189
if test "$tags"
190
then
191
- taglist=$(git-ls-remote --tags "$remote" |
192
- sed -e '
193
- /\^/d
194
- s/^[^ ]* //
195
- s/.*/.&:&/')
191
+ taglist=$(IFS=" " &&
192
+ git-ls-remote --tags "$remote" |
193
+ while read sha1 name
194
+ do
195
+ case "$name" in
196
+ (*^*) continue ;;
197
+ esac
198
+ if git-check-ref-format "$name"
199
+ then
200
+ echo ".${name}:${name}"
201
+ else
202
+ echo >&2 "warning: tag ${name} ignored"
203
+ fi
204
+ done)
205
if test "$#" -gt 1
206
then
207
# remote URL plus explicit refspecs; we need to merge them.