Skip to contentSkip to conversation

Ignore tags that contain colons in their names

PATCH In review Simon Richter 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Ignore tags that contain colons in their names

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

git-fetch.sh +1 -0
index 125bcea..6d930b2 100755
@@ -191,6 +191,7 @@ then
 	taglist=$(git-ls-remote --tags "$remote" |
 		sed -e '
 			/\^/d
+			/:/d
 			s/^[^	]*	//
 			s/.*/.&:&/')
 	if test "$#" -gt 1
#1 lore raw
Quoted 3 lines · Simon Richter

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.

---

git-fetch.sh +14 -5
index 125bcea..b46b3e5 100755
@@ -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.