Git development
 help / color / mirror / Atom feed
From: Alex Vandiver <alex@chmrr.net>
To: Ken Dreyer <ktdreyer@ktdreyer.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] cvsimport: strip all inappropriate tag strings
Date: Wed, 05 Sep 2012 02:44:29 -0400	[thread overview]
Message-ID: <1346827469.1137.22.camel@umgah.localdomain> (raw)
In-Reply-To: <1346819164-8116-1-git-send-email-ktdreyer@ktdreyer.com>

On Tue, 2012-09-04 at 22:26 -0600, Ken Dreyer wrote:
> When importing CVS tags, strip all the inappropriate strings from the
> tag names as we translate them to git tag names.
>
> [snip]
> diff --git a/git-cvsimport.perl b/git-cvsimport.perl
> index 8d41610..0dc598d 100755
> --- a/git-cvsimport.perl
> +++ b/git-cvsimport.perl
> @@ -889,7 +889,25 @@ 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 end with a '/' - this is already handled above.
> +		# Tag cannot contain bad chars. See bad_ref_char in ref.c.
> +		$xtag =~ s/[ ~\^:\\\*\?\[]//g;
> +		# Tag cannot contain '..'.
> +		$xtag =~ s/\.\.//g;
> +		# Tag cannot contain '@{'.
> +		$xtag =~ s/\@{//g;
> +		# Tag cannot end with '.lock'.
> +		$xtag =~ s/(?:\.lock)+$//;
> +		# Tag cannot begin or end with '.'.
> +		$xtag =~ s/^\.+//;
> +		$xtag =~ s/\.+$//;
> +		# Tag cannot consist of a single '.' - already handled above.
> +		# Tag cannot be empty.
> +		if ($xtag eq '') {
> +			return;
> +		}

Unfortunately, this isn't quite sufficient.  Consider the case of a tag
named "foo.lock."  The .lock rule doesn't match, because it's not at the
end of the string -- but after s/\.+$// runs, it _is_ at the end, and
hence invalid.  A similar problem exists with a tag named "a.@{.b",
given the ordering of @{ and .. removal.

Something like the following would suffice:

    1 while $xtag =~ s/
               (?: \.\.        # Tag cannot contain '..'.
               |   \@{         # Tag cannot contain '@{'.
               |   \.lock $    # Tag cannot end with '.lock'.
               | ^ \.          # Tag cannot begin...
               |   \. $        # ...or end with '.'
               )//xg;

 - Alex

  parent reply	other threads:[~2012-09-05  7:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05  2:53 [PATCH] cvsimport: strip question marks from tags Ken Dreyer
2012-09-05  3:19 ` Junio C Hamano
2012-09-05  4:26   ` [PATCH] cvsimport: strip all inappropriate tag strings Ken Dreyer
2012-09-05  5:52     ` Junio C Hamano
2012-09-05  6:44     ` Alex Vandiver [this message]
2012-09-05 21:39       ` Ken Dreyer
2012-09-06  3:52         ` Junio C Hamano
2012-09-06  5:42           ` Ken Dreyer
2012-09-06  9:02             ` Andreas Schwab
2012-09-06 16:36               ` Ken Dreyer
2012-09-06 17:41                 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346827469.1137.22.camel@umgah.localdomain \
    --to=alex@chmrr.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ktdreyer@ktdreyer.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox