Skip to content

Commit 81214e4

Browse files
author
Junio C Hamano
committed
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>
1 parent 353ce81 commit 81214e4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

git-fetch.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,20 @@ esac
188188
reflist=$(get_remote_refs_for_fetch "$@")
189189
if test "$tags"
190190
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)
196205
if test "$#" -gt 1
197206
then
198207
# remote URL plus explicit refspecs; we need to merge them.

0 commit comments

Comments
 (0)