{"thread":{"id":"1737","subject":"[PATCH] git-cvsimport-script: handling of tags","startedAt":"2005-09-06T17:36:01Z","lastAt":"2005-09-07T02:48:50Z","messageCount":10,"participants":["H. Peter Anvin","Junio C Hamano","Martin Langhoff"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"8129","messageId":"431DD381.4050709@zytor.com","threadId":"1737","inReplyTo":null,"subject":"[PATCH] git-cvsimport-script: handling of tags","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-06T17:36:01Z","receivedAt":"2005-09-06T17:36:01Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"This patch changes git-cvsimport-script so that it creates tag objects \ninstead of refs to commits, and adds an option, -u, to convert \nunderscores in branch and tag names to dots (since CVS doesn't allow \ndots in branches and tags.)\n\nPullable tree at master.kernel.org:/home/hpa/git/cvsimport.git/\n\n\t-hpa\n\n\ndiff --git a/Documentation/git-cvsimport-script.txt b/Documentation/git-cvsimport-script.txt\n--- a/Documentation/git-cvsimport-script.txt\n+++ b/Documentation/git-cvsimport-script.txt\n@@ -44,6 +44,9 @@ OPTIONS\n \tto avoid noisy changesets. Highly recommended, but off by default\n \tto preserve compatibility with early imported trees. \n \n+-u::\n+\tConvert underscores in tag and branch names to dots.\n+\n -o <branch-for-HEAD>::\n \tThe 'HEAD' branch from CVS is imported to the 'origin' branch within\n \tthe git repository, as 'HEAD' already has a special meaning for git.\ndiff --git a/git-cvsimport-script b/git-cvsimport-script\n--- a/git-cvsimport-script\n+++ b/git-cvsimport-script\n@@ -24,23 +24,24 @@ use Time::Local;\n use IO::Socket;\n use IO::Pipe;\n use POSIX qw(strftime dup2);\n+use IPC::Open2;\n \n $SIG{'PIPE'}=\"IGNORE\";\n $ENV{'TZ'}=\"UTC\";\n \n-our($opt_h,$opt_o,$opt_v,$opt_k,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_s,$opt_m,$opt_M);\n+our($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_s,$opt_m,$opt_M);\n \n sub usage() {\n \tprint STDERR <<END;\n Usage: ${\\basename $0}     # fetch/update GIT from CVS\n-       [ -o branch-for-HEAD ] [ -h ] [ -v ] [ -d CVSROOT ]\n-       [ -p opts-for-cvsps ] [ -C GIT_repository ] [ -z fuzz ]\n-       [ -i ] [ -k ] [-s subst] [ -m ] [ -M regex] [ CVS_module ]\n+       [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT]\n+       [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz]\n+       [-i] [-k] [-u] [-s subst] [-m] [-M regex] [CVS_module]\n END\n \texit(1);\n }\n \n-getopts(\"hivmko:d:p:C:z:s:M:\") or usage();\n+getopts(\"hivmkuo:d:p:C:z:s:M:\") or usage();\n usage if $opt_h;\n \n @ARGV <= 1 or usage();\n@@ -628,13 +629,37 @@ my $commit = sub {\n \t\tor die \"Cannot write branch $branch for update: $!\\n\";\n \n \tif($tag) {\n-\t\topen(C,\">$git_dir/refs/tags/$tag\")\n-\t\t\tor die \"Cannot create tag $tag: $!\\n\";\n-\t\tprint C \"$cid\\n\"\n-\t\t\tor die \"Cannot write tag $branch: $!\\n\";\n+\t\tmy($in, $out) = ('','');\n+\t        my($xtag) = $tag;\n+\t\t$xtag =~ s/\\s+\\*\\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **\n+\t\t$xtag =~ tr/_/\\./ if ( $opt_u );\n+\t\t\n+\t\tmy $pid = open2($in, $out, 'git-mktag');\n+\t\tprint $out \"object $cid\\n\".\n+\t\t    \"type commit\\n\".\n+\t\t    \"tag $xtag\\n\".\n+\t\t    \"tagger $author <$author>\\n\"\n+\t\t    or die \"Cannot create tag object $xtag: $!\\n\";\n+\t\tclose($out)\n+\t\t    or die \"Cannot create tag object $xtag: $!\\n\";\n+\n+\t\tmy $tagobj = <$in>;\n+\t\tchomp $tagobj;\n+\n+\t\tif ( !close($in) or waitpid($pid, 0) != $pid or\n+\t\t     $? != 0 or $tagobj !~ /^[0123456789abcdef]{40}$/ ) {\n+\t\t    die \"Cannot create tag object $xtag: $!\\n\";\n+\t        }\n+\t\t\n+\n+\t\topen(C,\">$git_dir/refs/tags/$xtag\")\n+\t\t\tor die \"Cannot create tag $xtag: $!\\n\";\n+\t\tprint C \"$tagobj\\n\"\n+\t\t\tor die \"Cannot write tag $xtag: $!\\n\";\n \t\tclose(C)\n-\t\t\tor die \"Cannot write tag $branch: $!\\n\";\n-\t\tprint \"Created tag '$tag' on '$branch'\\n\" if $opt_v;\n+\t\t\tor die \"Cannot write tag $xtag: $!\\n\";\n+\n+\t\tprint \"Created tag '$xtag' on '$branch'\\n\" if $opt_v;\n \t}\n };\n \n"},{"id":"8132","messageId":"431DE640.8050901@zytor.com","threadId":"1737","inReplyTo":"431DD381.4050709@zytor.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-06T18:56:00Z","receivedAt":"2005-09-06T18:56:00Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"H. Peter Anvin wrote:\n> This patch changes git-cvsimport-script so that it creates tag objects \n> instead of refs to commits, and adds an option, -u, to convert \n> underscores in branch and tag names to dots (since CVS doesn't allow \n> dots in branches and tags.)\n> \n> Pullable tree at master.kernel.org:/home/hpa/git/cvsimport.git/\n\nI should probably point out that there are still bugs in \ngit-cvsimport-script; for one thing, it seems to fail to register a tag \nassociated with the head, and I have yet to get the \"recognize merge\" \nfeature to actually work.  It's also possible -- but I haven't verified \nit -- that two tags which are aliases may not be properly registered.\n\n\t-hpa\n"},{"id":"8133","messageId":"7vwtluaum0.fsf@assigned-by-dhcp.cox.net","threadId":"1737","inReplyTo":"431DD381.4050709@zytor.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-06T19:01:27Z","receivedAt":"2005-09-06T19:01:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H. Peter Anvin\" <hpa@zytor.com> writes:\n\n> This patch changes git-cvsimport-script so that it creates tag objects \n> instead of refs to commits, and adds an option, -u, to convert \n> underscores in branch and tag names to dots (since CVS doesn't allow \n> dots in branches and tags.)\n\nLooks good.  Thanks.\n"},{"id":"8139","messageId":"431DFB04.5020701@zytor.com","threadId":"1737","inReplyTo":"431DE640.8050901@zytor.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-06T20:24:36Z","receivedAt":"2005-09-06T20:24:36Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"H. Peter Anvin wrote:\n> H. Peter Anvin wrote:\n> \n>> This patch changes git-cvsimport-script so that it creates tag objects \n>> instead of refs to commits, and adds an option, -u, to convert \n>> underscores in branch and tag names to dots (since CVS doesn't allow \n>> dots in branches and tags.)\n>>\n>> Pullable tree at master.kernel.org:/home/hpa/git/cvsimport.git/\n> \n> \n> I should probably point out that there are still bugs in \n> git-cvsimport-script; for one thing, it seems to fail to register a tag \n> associated with the head, and I have yet to get the \"recognize merge\" \n> feature to actually work.  It's also possible -- but I haven't verified \n> it -- that two tags which are aliases may not be properly registered.\n> \n\nI just verified this; git-cvsimport-script will not handle more than one \ntag per commit.\n\n\t-hpa\n"},{"id":"8143","messageId":"46a038f905090614216eca87eb@mail.gmail.com","threadId":"1737","inReplyTo":"431DFB04.5020701@zytor.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-09-06T21:21:24Z","receivedAt":"2005-09-06T21:21:24Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 9/7/05, H. Peter Anvin <hpa@zytor.com> wrote:\n> > I should probably point out that there are still bugs in\n> > git-cvsimport-script; for one thing, it seems to fail to register a tag\n> > associated with the head, and I have yet to get the \"recognize merge\"\n> > feature to actually work.  It's also possible -- but I haven't verified\n> > it -- that two tags which are aliases may not be properly registered.\n> I just verified this; git-cvsimport-script will not handle more than one\n> tag per commit.\n\nTell me more about how you are trying the 'recognize merge'. It is a\npretty unsophisticated thing, as it trusts the commit message in the\nfirst place. But when it works, it works.\n\nI have a more refined merge detection already working in the Arch\nimports -- patch coming soon -- but with cvs it is pretty hard to do.\n\ncheers,\n\n\nmartin\n"},{"id":"8144","messageId":"431E0B25.5000104@zytor.com","threadId":"1737","inReplyTo":"46a038f905090614216eca87eb@mail.gmail.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-06T21:33:25Z","receivedAt":"2005-09-06T21:33:25Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Martin Langhoff wrote:\n> \n> Tell me more about how you are trying the 'recognize merge'. It is a\n> pretty unsophisticated thing, as it trusts the commit message in the\n> first place. But when it works, it works.\n> \n\nPerhaps it would be good to know what it expects in the commit message?\n\nMy style has always be to use tags for merges; tag the origin branch as \nwell as before and after on the receiving branch.\n\n\t-hpa\n"},{"id":"8149","messageId":"46a038f9050906155962d33869@mail.gmail.com","threadId":"1737","inReplyTo":"431E0B25.5000104@zytor.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-09-06T22:59:26Z","receivedAt":"2005-09-06T22:59:26Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 9/7/05, H. Peter Anvin <hpa@zytor.com> wrote:\n> Martin Langhoff wrote:\n> >\n> > Tell me more about how you are trying the 'recognize merge'. It is a\n> > pretty unsophisticated thing, as it trusts the commit message in the\n> > first place. But when it works, it works.\n> >\n> \n> Perhaps it would be good to know what it expects in the commit message?\n\n>From the source, with line numbers:\n\n80 our @mergerx = ();\n81 if ($opt_m) {\n82     @mergerx = ( qr/\\W(?:from|of|merge|merging|merged) (\\w+)/i );\n83 }\n84 if ($opt_M) {\n85     push (@mergerx, qr/$opt_M/);\n86 }\n\nIf your commit messages have a particular format, feed -M a regex that\ncaptures the branchname/tagname in $1.\n\n> My style has always be to use tags for merges; tag the origin branch as\n> well as before and after on the receiving branch.\n\nDo you move the tags with cvs tag -F? If that's the case, the data you\nneed to merge is lost... otherwise, you could hack an alternative\nmerge detection based on your tagnames.\n\ncheers,\n\n\n\nmartin\n"},{"id":"8151","messageId":"431E2404.6060804@zytor.com","threadId":"1737","inReplyTo":"46a038f9050906155962d33869@mail.gmail.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-06T23:19:32Z","receivedAt":"2005-09-06T23:19:32Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Martin Langhoff wrote:\n> \n>>My style has always be to use tags for merges; tag the origin branch as\n>>well as before and after on the receiving branch.\n> \n> Do you move the tags with cvs tag -F? If that's the case, the data you\n> need to merge is lost... otherwise, you could hack an alternative\n> merge detection based on your tagnames.\n> \n\nNo, there are three tags:\n\n             before-merge-foo\n             |  after-merge-foo\n             |  |\nbranch 1 ---*--*----\n               /\n              /\nbranch 2 ---*-------\n             |\n             merge-point-foo\n\nThat's why I was a bit confused.  I thought most people did something \nsimilar.\n\n\t-hpa\n"},{"id":"8157","messageId":"46a038f905090619444f94292e@mail.gmail.com","threadId":"1737","inReplyTo":"431DD381.4050709@zytor.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-09-07T02:44:40Z","receivedAt":"2005-09-07T02:44:40Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 9/7/05, H. Peter Anvin <hpa@zytor.com> wrote:\n> This patch changes git-cvsimport-script so that it creates tag objects\n> instead of refs to commits, and adds an option, -u, to convert\n> underscores in branch and tag names to dots (since CVS doesn't allow\n> dots in branches and tags.)\n\nlooks good. Will it add proper tag objects for tags already imported\nand for tags added to the project post-initial-git-import?\n\ncheers,\n\n\nmartin\n"},{"id":"8158","messageId":"431E5512.7090900@zytor.com","threadId":"1737","inReplyTo":"46a038f905090619444f94292e@mail.gmail.com","subject":"Re: [PATCH] git-cvsimport-script: handling of tags","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-07T02:48:50Z","receivedAt":"2005-09-07T02:48:50Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Martin Langhoff wrote:\n> On 9/7/05, H. Peter Anvin <hpa@zytor.com> wrote:\n> \n>>This patch changes git-cvsimport-script so that it creates tag objects\n>>instead of refs to commits, and adds an option, -u, to convert\n>>underscores in branch and tag names to dots (since CVS doesn't allow\n>>dots in branches and tags.)\n> \n> \n> looks good. Will it add proper tag objects for tags already imported\n> and for tags added to the project post-initial-git-import?\n> \n\nNo and yes, respectively.\n\nI incorrectly stated it renamed both branches and tags.  It currently \nonly renames tags.  I'm trying to get branch renaming to work, but it \nseems to be a lot more work to get right.\n\n\t-hpa\n"}]}