# [PATCH] Ignore tags that contain colons in their names

2 messages from 2006-01-04 to 2006-01-06. Participants: Simon Richter, Junio C Hamano.
Thread: https://gitlist.dev/t/2964

## Simon Richter, 2006-01-04 13:13

Subject: [PATCH] Ignore tags that contain colons in their names
Message-ID: <43BBCA0A.6020906@kleinhenz.de>
URL: https://gitlist.dev/e/43BBCA0A.6020906%40kleinhenz.de

```
Hi,

a repo I was trying to clone contained a tag that somehow had a colon in 
its name, which is illegal. The attached patch makes git-fetch ignore 
these tags rather than barf.

    Simon


diff --git a/git-fetch.sh b/git-fetch.sh
index 125bcea..6d930b2 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -191,6 +191,7 @@ then
 	taglist=$(git-ls-remote --tags "$remote" |
 		sed -e '
 			/\^/d
+			/:/d
 			s/^[^	]*	//
 			s/.*/.&:&/')
 	if test "$#" -gt 1

```

## Junio C Hamano, 2006-01-06 22:37

Subject: Re: [PATCH] Ignore tags that contain colons in their names
Message-ID: <7v1wzlrni2.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v1wzlrni2.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <43BBCA0A.6020906@kleinhenz.de>

```
Simon Richter <Simon.Richter@kleinhenz.de> writes:

> a repo I was trying to clone contained a tag that somehow had a colon
> in its name, which is illegal. The attached patch makes git-fetch
> ignore these tags rather than barf.

Good intentions, but colon is not the only character.
I suspect we need to do something like this instead.

---
diff --git a/git-fetch.sh b/git-fetch.sh
index 125bcea..b46b3e5 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -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.

```
