git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] cvsimport: strip all inappropriate tag strings

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 6, 2012, 03:52 UTC
Message-ID
<7vipbr6c4q.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1346881194-19076-1-git-send-email-ktdreyer@ktdreyer.com>
Ken Dreyer <ktdreyer@ktdreyer.com> writes:
Show 13 quoted lines
> Certain characters such as "?" can be present in a CVS tag name, but
> git does not allow these characters in tags. If git-cvsimport
> encounters a CVS tag that git cannot handle, cvsimport will error and
> refuse to continue the import beyond that point.
>
> When importing CVS tags, strip all the inappropriate strings from the
> tag names as we translate them to git tag names.
>
> Signed-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>
> ---
>
> Thanks Junio and Alex for your review and comments. I've implemented
> both of your suggestions in this patch.
Thanks.

Do we want to give a warning instead of silently dropping a tag on the floor, or is the output verbose enough that such a warning will be drowned in the noise?

Show 27 quoted lines
>  git-cvsimport.perl | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/git-cvsimport.perl b/git-cvsimport.perl
> index 8d41610..dda8a6d 100755
> --- a/git-cvsimport.perl
> +++ b/git-cvsimport.perl
> @@ -889,7 +889,23 @@ sub commit {
>  		$xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **
>  		$xtag =~ tr/_/\./ if ( $opt_u );
>  		$xtag =~ s/[\/]/$opt_s/g;
> -		$xtag =~ s/\[//g;
> +
> +		# See ref.c for these rules.
> +		# Tag cannot contain bad chars. See bad_ref_char in ref.c.
> +		$xtag =~ s/[ ~\^:\\\*\?\[]//g;
> +		# Other bad strings for tags:
> +		1 while $xtag =~ s/
> +			(?: \.\.        # Tag cannot contain '..'.
> +			|   \@{         # Tag cannot contain '@{'.
> +			| ^ -           # Tag cannot begin with '-'.
> +			|   \.lock $    # Tag cannot end with '.lock'.
> +			| ^ \.          # Tag cannot begin...
> +			|   \. $        # ...or end with '.'
> +			)//xg;
> +		# Tag cannot be empty.
> +		if ($xtag eq '') {
That is, adding something like:
	print STDERR "warning: ignoring tag '$tag' with invalid tagname";
here.
Show 5 quoted lines
> +			return;
> +		}
>  
>  		system('git' , 'tag', '-f', $xtag, $cid) == 0
>  			or die "Cannot create tag $xtag: $!\n";

It also may be worthwhile to show the original tagname ($tag) somewhere in this message to help diagnosis.

Previous: Ken DreyerNext: Ken Dreyer
Message 7 of 11 in “cvsimport: strip question marks from tags”
  1. cvsimport: strip question marks from tagsKen Dreyer, Sep 5, 2012
  2. Junio C HamanoSep 5, 2012
  3. cvsimport: strip all inappropriate tag stringsKen Dreyer, Sep 5, 2012
  4. Junio C HamanoSep 5, 2012
  5. Alex VandiverSep 5, 2012
  6. cvsimport: strip all inappropriate tag stringsKen Dreyer, Sep 5, 2012
  7. Junio C HamanoSep 6, 2012
  8. cvsimport: strip all inappropriate tag stringsKen Dreyer, Sep 6, 2012
  9. Andreas SchwabSep 6, 2012
  10. cvsimport: strip all inappropriate tag stringsKen Dreyer, Sep 6, 2012
  11. Junio C HamanoSep 6, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.