Re: [PATCH] cvsimport: strip all inappropriate tag strings
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 5, 2012, 05:52 UTC
- Message-ID
- <7vobll6moz.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1346819164-8116-1-git-send-email-ktdreyer@ktdreyer.com>
Ken Dreyer <ktdreyer@ktdreyer.com> writes:
Show 10 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, will queue.
I think we also forbid tagnames (or branchnames for that matter) that begin with a dash on the creation side, even though the reading side tries to be lenient (i.e. if for some bad tool already created a file .git/refs/tags/-foobar, we allow "git show tags/-foobar" to show it). The routines in refs.c enforces primarily on the reading codepath. So this part:
> + # Tag cannot begin or end with '.'. > + $xtag =~ s/^\.+//; > + $xtag =~ s/\.+$//;
may need to become
# Tag cannot begin with '.' or '-', or end with '.'. $xtag =~ s/^[-.]+//; $xtag =~ s/\.+$//;
or something.
Show 34 quoted lines
> git-cvsimport.perl | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> 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;
> + }
>
> system('git' , 'tag', '-f', $xtag, $cid) == 0
> or die "Cannot create tag $xtag: $!\n";