# [PATCH] Change git-cvsimport to handle slashes in CVS tags

5 messages from 2005-10-28 to 2005-10-28. Participants: Wayne Scott, Johannes Schindelin, Linus Torvalds, Junio C Hamano, H. Peter Anvin.
Thread: https://gitlist.dev/t/2258

## Wayne Scott, 2005-10-28 18:46

Subject: [PATCH] Change git-cvsimport to handle slashes in CVS tags
Message-ID: <59a6e5830510281146s7b25da76l8bf97287522b89f2@mail.gmail.com>
URL: https://gitlist.dev/e/59a6e5830510281146s7b25da76l8bf97287522b89f2%40mail.gmail.com

```
The Tcl/Tk CVS tree contains some tags like this one:
  dev-stubs-merge-8-1-3/9/99

CVS doesn't mind that tag, but git can't handle the slash
characters in the tag.  Just change those to underscore
so imports can complete.

Signed-off-by: Wayne Scott <wsc9tt@gmail.com>
---

 git-cvsimport.perl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

applies-to: cf6439199f61d87dbb70fd7b43144e41462a359d
225c95454711467fc889c15cb3f7ca3230fce58d
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index bbb83fb..d71c30c 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -636,6 +636,7 @@ my $commit = sub {
                my($xtag) = $tag;
                $xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and *
* FUNKY **
                $xtag =~ tr/_/\./ if ( $opt_u );
+               $xtag =~ tr/\//_/;

                my $pid = open2($in, $out, 'git-mktag');
                print $out "object $cid\n".
---
0.99.8.GIT

```

## Johannes Schindelin, 2005-10-28 18:58

Subject: Re: [PATCH] Change git-cvsimport to handle slashes in CVS tags
Message-ID: <Pine.LNX.4.63.0510282058120.13531@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0510282058120.13531%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <59a6e5830510281146s7b25da76l8bf97287522b89f2@mail.gmail.com>

```
Hi,

http://www.gelato.unsw.edu.au/archives/git/0508/7825.html

Ciao,
Dscho

```

## Linus Torvalds, 2005-10-28 19:10

Subject: Re: [PATCH] Change git-cvsimport to handle slashes in CVS tags
Message-ID: <Pine.LNX.4.64.0510281151450.4664@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0510281151450.4664%40g5.osdl.org
In-Reply-To: <59a6e5830510281146s7b25da76l8bf97287522b89f2@mail.gmail.com>

```

Hmm.. git can certainly handle slashes in tags, but you'd need to 
basically "mkdir" the path up to there before creating them. 

That's probably not the right thing to do for a tag that comes from the 
outside, since in git, the slashes work like in a filesystem, and should 
imply grouping (ie you might have a family of tags that is named by 
usage, and be called something like "release/xyz" or whatever).

Is "_" the right thing to replace it with, though? To me, "_" replaces 
either a space or a dash, while a slash could be replaced by something 
more like a special character.

Maybe it's just me, but your example "dev-stubs-merge-8-1-3/9/99" might
look nicer either of these ways:

 - dev-stubs-merge-8-1-3|9|99 (but "|" is hard to use with shell)
 - dev-stubs-merge-8-1-3.9.99 (CVS tags can't contain '.', right?)
 - dev-stubs-merge-8-1-3:9:99 (confuse with time?)
 - dev-stubs-merge-8-1-3+9+99 (one arithmetic op replaced by another)
 - dev-stubs-merge-8-1-3#9#99 (that's pretty ugly)
 - dev-stubs-merge-8-1-3?9?99 (Wayne might be right after all)
 - dev-stubs-merge-8-1-3_9_99 (maybe Wayne _is_ right?)

I dunno. But maybe we do want the option of just keeping it as a slash, 
and teach git-cvsimport to create the proper subdirectory prefixes.

I have no idea how to do that in perl, though. Right now it just does

	open(C,">$git_dir/refs/tags/$xtag")

how would you do "create file with all path components"?

		Linus

```

## Junio C Hamano, 2005-10-28 20:29

Subject: Re: [PATCH] Change git-cvsimport to handle slashes in CVS tags
Message-ID: <7vmzkt4c7s.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vmzkt4c7s.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.64.0510281151450.4664@g5.osdl.org>

```
Linus Torvalds <torvalds@osdl.org> writes:

> I dunno. But maybe we do want the option of just keeping it as a slash, 
> and teach git-cvsimport to create the proper subdirectory prefixes.

How about doing both?

I think patch by Johannes to allow replacing slash to arbitrary
string is a reasonable thing to have, but somebody who uses
cvsimport needs to sign that off for me -- I do not regularly
use git-ANYimport myself.

> I have no idea how to do that in perl, though. Right now it just does
>
> 	open(C,">$git_dir/refs/tags/$xtag")
>
> how would you do "create file with all path components"?

Something like this? 

use File::Path;
my $file = "$git_dir/refs/tags/$xtag";
my ($dir) =  $file =~ m/(.*)\//;
mkpath($dir) && open C, ">$file";

```

## H. Peter Anvin, 2005-10-28 20:47

Subject: Re: [PATCH] Change git-cvsimport to handle slashes in CVS tags
Message-ID: <43628E6A.7000104@zytor.com>
URL: https://gitlist.dev/e/43628E6A.7000104%40zytor.com
In-Reply-To: <Pine.LNX.4.64.0510281151450.4664@g5.osdl.org>

```
Linus Torvalds wrote:
> 
> Is "_" the right thing to replace it with, though? To me, "_" replaces 
> either a space or a dash, while a slash could be replaced by something 
> more like a special character.
> 

If nothing else it creates a nice symmetry, since CVS can't use '.' in 
tags (which only is the most common character in nearly all versioning 
schemes), and which is commonly replaced by '_'.  We already have the -m 
option to change that back to dots, so we'd go:

'/' -> '_' -> '.'

... which at least means no info loss.

	-hpa

```
