{"thread":{"id":"31440","subject":"[PATCH] cvsimport: strip question marks from tags","startedAt":"2012-09-05T02:53:38Z","lastAt":"2012-09-06T17:41:54Z","messageCount":11,"participants":["Ken Dreyer","Junio C Hamano","Alex Vandiver","Andreas Schwab"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"198353","messageId":"1346813618-20279-1-git-send-email-ktdreyer@ktdreyer.com","threadId":"31440","inReplyTo":null,"subject":"[PATCH] cvsimport: strip question marks from tags","fromName":"Ken Dreyer","fromEmail":"ktdreyer@ktdreyer.com","sentAt":"2012-09-05T02:53:38Z","receivedAt":"2012-09-05T02:53:38Z","isPatch":true,"sender":{"key":"ktdreyer@ktdreyer.com","avatar":"https://avatars.githubusercontent.com/u/620295?v=4"},"body":"The \"?\" character can be present in a CVS tag name, but git's\nbad_ref_char does not allow question marks in git tags. If\ngit-cvsimport encounters a CVS tag with a question mark, it will error\nand refuse to continue the import beyond that point.\n\nWhen importing CVS tags, strip \"?\" characters from the tag names as we\ntranslate them to git tag names.\n\nSigned-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>\n---\n git-cvsimport.perl | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8d41610..36f59fe 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -890,6 +890,7 @@ sub commit {\n \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n \t\t$xtag =~ s/[\\/]/$opt_s/g;\n \t\t$xtag =~ s/\\[//g;\n+\t\t$xtag =~ s/\\?//g;\n \n \t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n-- \n1.7.11.4\n"},{"id":"198354","messageId":"7vsjax6trn.fsf@alter.siamese.dyndns.org","threadId":"31440","inReplyTo":"1346813618-20279-1-git-send-email-ktdreyer@ktdreyer.com","subject":"Re: [PATCH] cvsimport: strip question marks from tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-05T03:19:40Z","receivedAt":"2012-09-05T03:19:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ken Dreyer <ktdreyer@ktdreyer.com> writes:\n\n> The \"?\" character can be present in a CVS tag name, but git's\n> bad_ref_char does not allow question marks in git tags. If\n> git-cvsimport encounters a CVS tag with a question mark, it will error\n> and refuse to continue the import beyond that point.\n>\n> When importing CVS tags, strip \"?\" characters from the tag names as we\n> translate them to git tag names.\n>\n> Signed-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>\n> ---\n>  git-cvsimport.perl | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/git-cvsimport.perl b/git-cvsimport.perl\n> index 8d41610..36f59fe 100755\n> --- a/git-cvsimport.perl\n> +++ b/git-cvsimport.perl\n> @@ -890,6 +890,7 @@ sub commit {\n>  \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n>  \t\t$xtag =~ s/[\\/]/$opt_s/g;\n>  \t\t$xtag =~ s/\\[//g;\n> +\t\t$xtag =~ s/\\?//g;\n\nI do not think this is a right and sustainable approach.  The next\npatch would probably be to strip \"~\" and then another patch that\nstrips \"^\", and yet another that squashes \"..\" into one would surely\nfollow.\n\nHow about extending the s/\\[//g we can see in the context to cover\neverything that are unacceptable (see refs.c:bad_ref_char()) once\nand for all?  The result needs to be further massaged to avoid\ncomponent that has two or more dots in a row, a dot at the beginning\nor at the end (see the comment at the beginning of refs.c, and also\nrefs.c:check_refname_component()).\n\n>  \t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n>  \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n"},{"id":"198355","messageId":"1346819164-8116-1-git-send-email-ktdreyer@ktdreyer.com","threadId":"31440","inReplyTo":"7vsjax6trn.fsf@alter.siamese.dyndns.org","subject":"[PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Ken Dreyer","fromEmail":"ktdreyer@ktdreyer.com","sentAt":"2012-09-05T04:26:04Z","receivedAt":"2012-09-05T04:26:04Z","isPatch":true,"sender":{"key":"ktdreyer@ktdreyer.com","avatar":"https://avatars.githubusercontent.com/u/620295?v=4"},"body":"Certain characters such as \"?\" can be present in a CVS tag name, but\ngit does not allow these characters in tags. If git-cvsimport\nencounters a CVS tag that git cannot handle, cvsimport will error and\nrefuse to continue the import beyond that point.\n\nWhen importing CVS tags, strip all the inappropriate strings from the\ntag names as we translate them to git tag names.\n\nSigned-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>\n---\n\nThank you Junio for the review. I've taken your suggestion and amended\nmy patch to eliminate all the bad strings in ref.c. \n\n git-cvsimport.perl | 20 +++++++++++++++++++-\n 1 file changed, 19 insertions(+), 1 deletion(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8d41610..0dc598d 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -889,7 +889,25 @@ sub commit {\n \t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n \t\t$xtag =~ s/[\\/]/$opt_s/g;\n-\t\t$xtag =~ s/\\[//g;\n+\n+\t\t# See ref.c for these rules.\n+\t\t# Tag cannot end with a '/' - this is already handled above.\n+\t\t# Tag cannot contain bad chars. See bad_ref_char in ref.c.\n+\t\t$xtag =~ s/[ ~\\^:\\\\\\*\\?\\[]//g;\n+\t\t# Tag cannot contain '..'.\n+\t\t$xtag =~ s/\\.\\.//g;\n+\t\t# Tag cannot contain '@{'.\n+\t\t$xtag =~ s/\\@{//g;\n+\t\t# Tag cannot end with '.lock'.\n+\t\t$xtag =~ s/(?:\\.lock)+$//;\n+\t\t# Tag cannot begin or end with '.'.\n+\t\t$xtag =~ s/^\\.+//;\n+\t\t$xtag =~ s/\\.+$//;\n+\t\t# Tag cannot consist of a single '.' - already handled above.\n+\t\t# Tag cannot be empty.\n+\t\tif ($xtag eq '') {\n+\t\t\treturn;\n+\t\t}\n \n \t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n-- \n1.7.11.4\n"},{"id":"198356","messageId":"7vobll6moz.fsf@alter.siamese.dyndns.org","threadId":"31440","inReplyTo":"1346819164-8116-1-git-send-email-ktdreyer@ktdreyer.com","subject":"Re: [PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-05T05:52:28Z","receivedAt":"2012-09-05T05:52:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ken Dreyer <ktdreyer@ktdreyer.com> writes:\n\n> Certain characters such as \"?\" can be present in a CVS tag name, but\n> git does not allow these characters in tags. If git-cvsimport\n> encounters a CVS tag that git cannot handle, cvsimport will error and\n> refuse to continue the import beyond that point.\n>\n> When importing CVS tags, strip all the inappropriate strings from the\n> tag names as we translate them to git tag names.\n>\n> Signed-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>\n> ---\n\nThanks, will queue.\n\nI think we also forbid tagnames (or branchnames for that matter)\nthat begin with a dash on the creation side, even though the reading\nside tries to be lenient (i.e. if for some bad tool already created\na file .git/refs/tags/-foobar, we allow \"git show tags/-foobar\" to\nshow it).  The routines in refs.c enforces primarily on the reading\ncodepath.  So this part:\n\n> +\t\t# Tag cannot begin or end with '.'.\n> +\t\t$xtag =~ s/^\\.+//;\n> +\t\t$xtag =~ s/\\.+$//;\n\nmay need to become\n\n\t# Tag cannot begin with '.' or '-', or end with '.'.\n\t$xtag =~ s/^[-.]+//;\n\t$xtag =~ s/\\.+$//;\n\nor something.\n\n\n>  git-cvsimport.perl | 20 +++++++++++++++++++-\n>  1 file changed, 19 insertions(+), 1 deletion(-)\n>\n> diff --git a/git-cvsimport.perl b/git-cvsimport.perl\n> index 8d41610..0dc598d 100755\n> --- a/git-cvsimport.perl\n> +++ b/git-cvsimport.perl\n> @@ -889,7 +889,25 @@ sub commit {\n>  \t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n>  \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n>  \t\t$xtag =~ s/[\\/]/$opt_s/g;\n> -\t\t$xtag =~ s/\\[//g;\n> +\n> +\t\t# See ref.c for these rules.\n> +\t\t# Tag cannot end with a '/' - this is already handled above.\n> +\t\t# Tag cannot contain bad chars. See bad_ref_char in ref.c.\n> +\t\t$xtag =~ s/[ ~\\^:\\\\\\*\\?\\[]//g;\n> +\t\t# Tag cannot contain '..'.\n> +\t\t$xtag =~ s/\\.\\.//g;\n> +\t\t# Tag cannot contain '@{'.\n> +\t\t$xtag =~ s/\\@{//g;\n> +\t\t# Tag cannot end with '.lock'.\n> +\t\t$xtag =~ s/(?:\\.lock)+$//;\n> +\t\t# Tag cannot begin or end with '.'.\n> +\t\t$xtag =~ s/^\\.+//;\n> +\t\t$xtag =~ s/\\.+$//;\n> +\t\t# Tag cannot consist of a single '.' - already handled above.\n> +\t\t# Tag cannot be empty.\n> +\t\tif ($xtag eq '') {\n> +\t\t\treturn;\n> +\t\t}\n>  \n>  \t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n>  \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n"},{"id":"198358","messageId":"1346827469.1137.22.camel@umgah.localdomain","threadId":"31440","inReplyTo":"1346819164-8116-1-git-send-email-ktdreyer@ktdreyer.com","subject":"Re: [PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Alex Vandiver","fromEmail":"alex@chmrr.net","sentAt":"2012-09-05T06:44:29Z","receivedAt":"2012-09-05T06:44:29Z","isPatch":true,"sender":{"key":"alex@chmrr.net","avatar":"https://avatars.githubusercontent.com/u/28347?v=4"},"body":"On Tue, 2012-09-04 at 22:26 -0600, Ken Dreyer wrote:\n> When importing CVS tags, strip all the inappropriate strings from the\n> tag names as we translate them to git tag names.\n>\n> [snip]\n> diff --git a/git-cvsimport.perl b/git-cvsimport.perl\n> index 8d41610..0dc598d 100755\n> --- a/git-cvsimport.perl\n> +++ b/git-cvsimport.perl\n> @@ -889,7 +889,25 @@ sub commit {\n>  \t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n>  \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n>  \t\t$xtag =~ s/[\\/]/$opt_s/g;\n> -\t\t$xtag =~ s/\\[//g;\n> +\n> +\t\t# See ref.c for these rules.\n> +\t\t# Tag cannot end with a '/' - this is already handled above.\n> +\t\t# Tag cannot contain bad chars. See bad_ref_char in ref.c.\n> +\t\t$xtag =~ s/[ ~\\^:\\\\\\*\\?\\[]//g;\n> +\t\t# Tag cannot contain '..'.\n> +\t\t$xtag =~ s/\\.\\.//g;\n> +\t\t# Tag cannot contain '@{'.\n> +\t\t$xtag =~ s/\\@{//g;\n> +\t\t# Tag cannot end with '.lock'.\n> +\t\t$xtag =~ s/(?:\\.lock)+$//;\n> +\t\t# Tag cannot begin or end with '.'.\n> +\t\t$xtag =~ s/^\\.+//;\n> +\t\t$xtag =~ s/\\.+$//;\n> +\t\t# Tag cannot consist of a single '.' - already handled above.\n> +\t\t# Tag cannot be empty.\n> +\t\tif ($xtag eq '') {\n> +\t\t\treturn;\n> +\t\t}\n\nUnfortunately, this isn't quite sufficient.  Consider the case of a tag\nnamed \"foo.lock.\"  The .lock rule doesn't match, because it's not at the\nend of the string -- but after s/\\.+$// runs, it _is_ at the end, and\nhence invalid.  A similar problem exists with a tag named \"a.@{.b\",\ngiven the ordering of @{ and .. removal.\n\nSomething like the following would suffice:\n\n    1 while $xtag =~ s/\n               (?: \\.\\.        # Tag cannot contain '..'.\n               |   \\@{         # Tag cannot contain '@{'.\n               |   \\.lock $    # Tag cannot end with '.lock'.\n               | ^ \\.          # Tag cannot begin...\n               |   \\. $        # ...or end with '.'\n               )//xg;\n\n - Alex\n"},{"id":"198406","messageId":"1346881194-19076-1-git-send-email-ktdreyer@ktdreyer.com","threadId":"31440","inReplyTo":"1346827469.1137.22.camel@umgah.localdomain","subject":"[PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Ken Dreyer","fromEmail":"ktdreyer@ktdreyer.com","sentAt":"2012-09-05T21:39:54Z","receivedAt":"2012-09-05T21:39:54Z","isPatch":true,"sender":{"key":"ktdreyer@ktdreyer.com","avatar":"https://avatars.githubusercontent.com/u/620295?v=4"},"body":"Certain characters such as \"?\" can be present in a CVS tag name, but\ngit does not allow these characters in tags. If git-cvsimport\nencounters a CVS tag that git cannot handle, cvsimport will error and\nrefuse to continue the import beyond that point.\n\nWhen importing CVS tags, strip all the inappropriate strings from the\ntag names as we translate them to git tag names.\n\nSigned-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>\n---\n\nThanks Junio and Alex for your review and comments. I've implemented\nboth of your suggestions in this patch.\n\n git-cvsimport.perl | 18 +++++++++++++++++-\n 1 file changed, 17 insertions(+), 1 deletion(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8d41610..dda8a6d 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -889,7 +889,23 @@ sub commit {\n \t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n \t\t$xtag =~ s/[\\/]/$opt_s/g;\n-\t\t$xtag =~ s/\\[//g;\n+\n+\t\t# See ref.c for these rules.\n+\t\t# Tag cannot contain bad chars. See bad_ref_char in ref.c.\n+\t\t$xtag =~ s/[ ~\\^:\\\\\\*\\?\\[]//g;\n+\t\t# Other bad strings for tags:\n+\t\t1 while $xtag =~ s/\n+\t\t\t(?: \\.\\.        # Tag cannot contain '..'.\n+\t\t\t|   \\@{         # Tag cannot contain '@{'.\n+\t\t\t| ^ -           # Tag cannot begin with '-'.\n+\t\t\t|   \\.lock $    # Tag cannot end with '.lock'.\n+\t\t\t| ^ \\.          # Tag cannot begin...\n+\t\t\t|   \\. $        # ...or end with '.'\n+\t\t\t)//xg;\n+\t\t# Tag cannot be empty.\n+\t\tif ($xtag eq '') {\n+\t\t\treturn;\n+\t\t}\n \n \t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n-- \n1.7.11.4\n"},{"id":"198416","messageId":"7vipbr6c4q.fsf@alter.siamese.dyndns.org","threadId":"31440","inReplyTo":"1346881194-19076-1-git-send-email-ktdreyer@ktdreyer.com","subject":"Re: [PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-06T03:52:53Z","receivedAt":"2012-09-06T03:52:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ken Dreyer <ktdreyer@ktdreyer.com> writes:\n\n> Certain characters such as \"?\" can be present in a CVS tag name, but\n> git does not allow these characters in tags. If git-cvsimport\n> encounters a CVS tag that git cannot handle, cvsimport will error and\n> refuse to continue the import beyond that point.\n>\n> When importing CVS tags, strip all the inappropriate strings from the\n> tag names as we translate them to git tag names.\n>\n> Signed-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>\n> ---\n>\n> Thanks Junio and Alex for your review and comments. I've implemented\n> both of your suggestions in this patch.\n\nThanks.\n\nDo we want to give a warning instead of silently dropping a tag on\nthe floor, or is the output verbose enough that such a warning will\nbe drowned in the noise?\n\n>  git-cvsimport.perl | 18 +++++++++++++++++-\n>  1 file changed, 17 insertions(+), 1 deletion(-)\n>\n> diff --git a/git-cvsimport.perl b/git-cvsimport.perl\n> index 8d41610..dda8a6d 100755\n> --- a/git-cvsimport.perl\n> +++ b/git-cvsimport.perl\n> @@ -889,7 +889,23 @@ sub commit {\n>  \t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n>  \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n>  \t\t$xtag =~ s/[\\/]/$opt_s/g;\n> -\t\t$xtag =~ s/\\[//g;\n> +\n> +\t\t# See ref.c for these rules.\n> +\t\t# Tag cannot contain bad chars. See bad_ref_char in ref.c.\n> +\t\t$xtag =~ s/[ ~\\^:\\\\\\*\\?\\[]//g;\n> +\t\t# Other bad strings for tags:\n> +\t\t1 while $xtag =~ s/\n> +\t\t\t(?: \\.\\.        # Tag cannot contain '..'.\n> +\t\t\t|   \\@{         # Tag cannot contain '@{'.\n> +\t\t\t| ^ -           # Tag cannot begin with '-'.\n> +\t\t\t|   \\.lock $    # Tag cannot end with '.lock'.\n> +\t\t\t| ^ \\.          # Tag cannot begin...\n> +\t\t\t|   \\. $        # ...or end with '.'\n> +\t\t\t)//xg;\n> +\t\t# Tag cannot be empty.\n> +\t\tif ($xtag eq '') {\n\nThat is, adding something like:\n\n\tprint STDERR \"warning: ignoring tag '$tag' with invalid tagname\";\n\nhere.\n\n> +\t\t\treturn;\n> +\t\t}\n>  \n>  \t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n>  \t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n\nIt also may be worthwhile to show the original tagname ($tag)\nsomewhere in this message to help diagnosis.\n"},{"id":"198422","messageId":"1346910178-13902-1-git-send-email-ktdreyer@ktdreyer.com","threadId":"31440","inReplyTo":"7vipbr6c4q.fsf@alter.siamese.dyndns.org","subject":"[PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Ken Dreyer","fromEmail":"ktdreyer@ktdreyer.com","sentAt":"2012-09-06T05:42:58Z","receivedAt":"2012-09-06T05:42:58Z","isPatch":true,"sender":{"key":"ktdreyer@ktdreyer.com","avatar":"https://avatars.githubusercontent.com/u/620295?v=4"},"body":"Certain characters such as \"?\" can be present in a CVS tag name, but\ngit does not allow these characters in tags. If git-cvsimport\nencounters a CVS tag that git cannot handle, cvsimport will error and\nrefuse to continue the import beyond that point.\n\nWhen importing CVS tags, strip all the inappropriate strings from the\ntag names as we translate them to git tag names.\n\nProvide more debugging information to the user if we've altered the\ntag and the \"git tag\" command still fails. Also, warn the user if we\nend up skipping an (unusable) tag altogether.\n\nSigned-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>\n---\n\nThanks Junio for your suggestion about diagnosis messages. I've\nimplemented your suggestion by adding a warning statement if we skip a\ntag altogether, and I also added some output if we've translated a tag\nand the system() call still fails.\n\n git-cvsimport.perl | 32 +++++++++++++++++++++++++++++---\n 1 file changed, 29 insertions(+), 3 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8d41610..3a30754 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -889,10 +889,36 @@ sub commit {\n \t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n \t\t$xtag =~ s/[\\/]/$opt_s/g;\n-\t\t$xtag =~ s/\\[//g;\n \n-\t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n-\t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n+\t\t# See ref.c for these rules.\n+\t\t# Tag cannot contain bad chars. See bad_ref_char in ref.c.\n+\t\t$xtag =~ s/[ ~\\^:\\\\\\*\\?\\[]//g;\n+\t\t# Other bad strings for tags:\n+\t\t1 while $xtag =~ s/\n+\t\t\t(?: \\.\\.        # Tag cannot contain '..'.\n+\t\t\t|   \\@{         # Tag cannot contain '@{'.\n+\t\t\t| ^ -           # Tag cannot begin with '-'.\n+\t\t\t|   \\.lock $    # Tag cannot end with '.lock'.\n+\t\t\t| ^ \\.          # Tag cannot begin...\n+\t\t\t|   \\. $        # ...or end with '.'\n+\t\t\t)//xg;\n+\t\t# Tag cannot be empty.\n+\t\tif ($xtag eq '') {\n+\t\t\twarn(\"warning: ignoring tag '$tag'\",\n+\t\t\t\" with invalid tagname\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (system('git' , 'tag', '-f', $xtag, $cid) != 0) {\n+\t\t\t# We did our best to sanitize the tag, but still failed\n+\t\t\t# for whatever reason. Bail out, and give the user\n+\t\t\t# enough information to understand if/how we should\n+\t\t\t# improve the translation in the future.\n+\t\t\tif ($tag ne $xtag) {\n+\t\t\t\tprint \"Translated '$tag' tag to '$xtag'\\n\";\n+\t\t\t}\n+\t\t\tdie \"Cannot create tag $xtag: $!\\n\";\n+\t\t}\n \n \t\tprint \"Created tag '$xtag' on '$branch'\\n\" if $opt_v;\n \t}\n-- \n1.7.11.4\n"},{"id":"198428","messageId":"m2y5knjzh5.fsf@igel.home","threadId":"31440","inReplyTo":"1346910178-13902-1-git-send-email-ktdreyer@ktdreyer.com","subject":"Re: [PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-09-06T09:02:30Z","receivedAt":"2012-09-06T09:02:30Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Ken Dreyer <ktdreyer@ktdreyer.com> writes:\n\n> +\t\t# See ref.c for these rules.\n> +\t\t# Tag cannot contain bad chars. See bad_ref_char in ref.c.\n\ns/ref.c/refs.c/\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"198459","messageId":"1346949413-17287-1-git-send-email-ktdreyer@ktdreyer.com","threadId":"31440","inReplyTo":"m2y5knjzh5.fsf@igel.home","subject":"[PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Ken Dreyer","fromEmail":"ktdreyer@ktdreyer.com","sentAt":"2012-09-06T16:36:53Z","receivedAt":"2012-09-06T16:36:53Z","isPatch":true,"sender":{"key":"ktdreyer@ktdreyer.com","avatar":"https://avatars.githubusercontent.com/u/620295?v=4"},"body":"Certain characters such as \"?\" can be present in a CVS tag name, but\ngit does not allow these characters in tags. If git-cvsimport\nencounters a CVS tag that git cannot handle, cvsimport will error and\nrefuse to continue the import beyond that point.\n\nWhen importing CVS tags, strip all the inappropriate strings from the\ntag names as we translate them to git tag names.\n\nProvide more debugging information to the user if we've altered the\ntag and the \"git tag\" command still fails. Also, warn the user if we\nend up skipping an (unusable) tag altogether.\n\nSigned-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>\n---\n\nThanks Andreas for catching that \"ref.c\" in the comments ought to be\n\"refs.c\". I've corrected that in this latest version of the patch.\n\n git-cvsimport.perl | 33 ++++++++++++++++++++++++++++++---\n 1 file changed, 30 insertions(+), 3 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8d41610..8032f23 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -889,10 +889,37 @@ sub commit {\n \t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n \t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n \t\t$xtag =~ s/[\\/]/$opt_s/g;\n-\t\t$xtag =~ s/\\[//g;\n \n-\t\tsystem('git' , 'tag', '-f', $xtag, $cid) == 0\n-\t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n+\t\t# See refs.c for these rules.\n+\t\t# Tag cannot contain bad chars. (See bad_ref_char in refs.c.)\n+\t\t$xtag =~ s/[ ~\\^:\\\\\\*\\?\\[]//g;\n+\t\t# Other bad strings for tags:\n+\t\t# (See check_refname_component in refs.c.)\n+\t\t1 while $xtag =~ s/\n+\t\t\t(?: \\.\\.        # Tag cannot contain '..'.\n+\t\t\t|   \\@{         # Tag cannot contain '@{'.\n+\t\t\t| ^ -           # Tag cannot begin with '-'.\n+\t\t\t|   \\.lock $    # Tag cannot end with '.lock'.\n+\t\t\t| ^ \\.          # Tag cannot begin...\n+\t\t\t|   \\. $        # ...or end with '.'\n+\t\t\t)//xg;\n+\t\t# Tag cannot be empty.\n+\t\tif ($xtag eq '') {\n+\t\t\twarn(\"warning: ignoring tag '$tag'\",\n+\t\t\t\" with invalid tagname\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (system('git' , 'tag', '-f', $xtag, $cid) != 0) {\n+\t\t\t# We did our best to sanitize the tag, but still failed\n+\t\t\t# for whatever reason. Bail out, and give the user\n+\t\t\t# enough information to understand if/how we should\n+\t\t\t# improve the translation in the future.\n+\t\t\tif ($tag ne $xtag) {\n+\t\t\t\tprint \"Translated '$tag' tag to '$xtag'\\n\";\n+\t\t\t}\n+\t\t\tdie \"Cannot create tag $xtag: $!\\n\";\n+\t\t}\n \n \t\tprint \"Created tag '$xtag' on '$branch'\\n\" if $opt_v;\n \t}\n-- \n1.7.11.4\n"},{"id":"198464","messageId":"7v627r3v6l.fsf@alter.siamese.dyndns.org","threadId":"31440","inReplyTo":"1346949413-17287-1-git-send-email-ktdreyer@ktdreyer.com","subject":"Re: [PATCH] cvsimport: strip all inappropriate tag strings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-06T17:41:54Z","receivedAt":"2012-09-06T17:41:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ken Dreyer <ktdreyer@ktdreyer.com> writes:\n\n> Thanks Andreas for catching that \"ref.c\" in the comments ought to be\n> \"refs.c\". I've corrected that in this latest version of the patch.\n\nYeah, thanks, all.  Will queue.\n"}]}