git-fetch --tags: reject malformed tags.
authorJunio C Hamano <junkio@cox.net>
Fri, 6 Jan 2006 03:42:12 +0000 (19:42 -0800)
committerJunio C Hamano <junkio@cox.net>
Fri, 6 Jan 2006 03:42:12 +0000 (19:42 -0800)
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>
git-fetch.sh

index 125bcea1b6e9eef4e7f59f5f1ce511ad8fc3d43e..b46b3e558945a3afb783894c75ce20cede0b4eec 100755 (executable)
@@ -188,11 +188,20 @@ esac
 reflist=$(get_remote_refs_for_fetch "$@")
 if test "$tags"
 then
-       taglist=$(git-ls-remote --tags "$remote" |
-               sed -e '
-                       /\^/d
-                       s/^[^   ]*      //
-                       s/.*/.&:&/')
+       taglist=$(IFS=" " &&
+                 git-ls-remote --tags "$remote" |
+                 while read sha1 name
+                 do
+                       case "$name" in
+                       (*^*) continue ;;
+                       esac
+                       if git-check-ref-format "$name"
+                       then
+                           echo ".${name}:${name}"
+                       else
+                           echo >&2 "warning: tag ${name} ignored"
+                       fi
+                 done)
        if test "$#" -gt 1
        then
                # remote URL plus explicit refspecs; we need to merge them.