Skip to contentSkip to conversation

Use git-tag in git-cvsimport

PATCH In review Elvis Pranskevichus 4 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use git-tag in git-cvsimport

Currently git-cvsimport tries to create tag objects directly via git-mktag in a very broken way, e.g the stuff it writes into the tagger field of the tag object doesn't really resemble the GIT_COMMITTER_IDENT. This makes gitweb and possibly other tools that try to interpret tag objects to be confused about tag date and authorship.

Fix this by calling git-tag instead. This also has a nice side effect of not creating the tag object but only the lightweight tag as that's the only thing CVS has anyways.

---
 git-cvsimport.perl |   26 ++------------------------
 1 files changed, 2 insertions(+), 24 deletions(-)
git-cvsimport.perl +2 -24
index f68afe7..d5ca66b 100755
@@ -771,31 +771,9 @@ sub commit {
 		$xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **
 		$xtag =~ tr/_/\./ if ( $opt_u );
 		$xtag =~ s/[\/]/$opt_s/g;
-		
-		my $pid = open2($in, $out, 'git-mktag');
-		print $out "object $cid\n".
-		    "type commit\n".
-		    "tag $xtag\n".
-		    "tagger $author_name <$author_email>\n"
-		    or die "Cannot create tag object $xtag: $!\n";
-		close($out)
-		    or die "Cannot create tag object $xtag: $!\n";
-
-		my $tagobj = <$in>;
-		chomp $tagobj;
-
-		if ( !close($in) or waitpid($pid, 0) != $pid or
-		     $? != 0 or $tagobj !~ /^[0123456789abcdef]{40}$/ ) {
-		    die "Cannot create tag object $xtag: $!\n";
-	        }
-		
-
-		open(C,">$git_dir/refs/tags/$xtag")
+
+		system("git-tag $xtag $cid") == 0
 			or die "Cannot create tag $xtag: $!\n";
-		print C "$tagobj\n"
-			or die "Cannot write tag $xtag: $!\n";
-		close(C)
-			or die "Cannot write tag $xtag: $!\n";
 
 		print "Created tag '$xtag' on '$branch'\n" if $opt_v;
 	}
Signature · 1 line
1.5.2
#1 lore raw
Quoted 11 lines · Elvis Pranskevichus

Currently git-cvsimport tries to create tag objects directly via git-mktag in a very broken way, e.g the stuff it writes into the tagger field of the tag object doesn't really resemble the GIT_COMMITTER_IDENT. This makes gitweb and possibly other tools that try to interpret tag objects to be confused about tag date and authorship.

Fix this by calling git-tag instead. This also has a nice side effect of not creating the tag object but only the lightweight tag as that's the only thing CVS has anyways.

This sounds very sane, although I have not thought through the possible ramifications.

Quoted 21 lines
 git-cvsimport.perl |   26 ++------------------------
 1 files changed, 2 insertions(+), 24 deletions(-)
git-cvsimport.perl +2 -2
index f68afe7..d5ca66b 100755
@@ -771,31 +771,9 @@ sub commit {
 		$xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **
 		$xtag =~ tr/_/\./ if ( $opt_u );
 		$xtag =~ s/[\/]/$opt_s/g;
- ...
+
+		system("git-tag $xtag $cid") == 0
 			or die "Cannot create tag $xtag: $!\n";
- ...
 
 		print "Created tag '$xtag' on '$branch'\n" if $opt_v;
 	}
Signature · 1 line
1.5.2

Other than that I would write the "system" in a slightly newer style, i.e.

	system('git-tag', $xtag, $cid)

I do not think of any obvious downside, either in the code nor the change to use unannotated tag.

Anybody on the list see downsides with this?

#2 lore raw
Quoted 1 line

hoi :)

Hi =)

Quoted 7 lines · Junio C Hamano
Quoted 4 lines
Quoted 1 line · Martin Waitz

but lightweight tags are not fetched by default.

Are you sure about that?

not any more now that you questioned it ;-)

Last time I checked, unannotated tags are git-cloned and git-fetched just fine. I'm not sure about the exact definition and behaviour of lightweight tags, though.

CVS just doesn't attach any valuable info to the tags, it's just a point in time.

Quoted 3 lines

But at least there is a hook script which refuses to receive un-annotated tags and I always considered those tags to be temporary tags in the local repository.

Well, there's no mention about that in the docs. And I don't think that the notion of git losing valid objects along the way is the good one =)

Anyways, the patch wasn't about the tag type change. As I mentioned it's just a side effect. The main point is to fix the cvsimport tag breakage. I've tested that change on a few big (and messy) CVS repos, and it works just fine.

Cheers,

Signature · 1 line
                 Elvis
#3 lore raw
In reply to Elvis Pranskevichus

hoi :)

Quoted 3 lines · Elvis Pranskevichus

Fix this by calling git-tag instead. This also has a nice side effect of not creating the tag object but only the lightweight tag as that's the only thing CVS has anyways.

but lightweight tags are not fetched by default.
And only leaving them in the repository that actually did the cvsimport makes them much less valuable.

git-cvsimport.perl sub commit { · line 775

Quoted 2 lines
git-cvsimport.perl +2 -0
+
+		system("git-tag $xtag $cid") == 0

I suggest adding something like -m "import label from CVS".

Signature · 1 line
Martin Waitz
#4 lore raw
Quoted 8 lines · Martin Waitz

hoi :)

Quoted 3 lines · Elvis Pranskevichus

Fix this by calling git-tag instead. This also has a nice side effect of not creating the tag object but only the lightweight tag as that's the only thing CVS has anyways.

but lightweight tags are not fetched by default.

Are you sure about that?

#5 lore raw

hoi :)

Quoted 4 lines · Junio C Hamano
Quoted 1 line · Martin Waitz

but lightweight tags are not fetched by default.

Are you sure about that?

not any more now that you questioned it ;-)

But at least there is a hook script which refuses to receive un-annotated tags and I always considered those tags to be temporary tags in the local repository.

Signature · 1 line
Martin Waitz
#6 lore raw
Quoted 11 lines · Martin Waitz
Quoted 4 lines · Junio C Hamano
Quoted 1 line · Martin Waitz

but lightweight tags are not fetched by default.

Are you sure about that?

not any more now that you questioned it ;-)

But at least there is a hook script which refuses to receive un-annotated tags and I always considered those tags to be temporary tags in the local repository.

I'll take the patch to 'next' and see if anybody screams. We can add the '-m "Label from CVS"' bit easily if annotated tags turns out to be easier for people before it graduates to 'master', although I suspect we probably do not have to.