{"thread":{"id":"8354","subject":"[PATCH] cvsimport: add support for new style remote layout","startedAt":"2007-05-30T00:56:41Z","lastAt":"2007-06-06T11:52:24Z","messageCount":7,"participants":["Andy Whitcroft","James Bowes","Junio C Hamano","Jeffrey C. Ollie"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43594","messageId":"3a477a76f6c5396feee452678fb8110c@pinky","threadId":"8354","inReplyTo":null,"subject":"[PATCH] cvsimport: add support for new style remote layout","fromName":"Andy Whitcroft","fromEmail":"apw@shadowen.org","sentAt":"2007-05-30T00:56:41Z","receivedAt":"2007-05-30T00:56:41Z","isPatch":true,"sender":{"key":"apw@shadowen.org","avatar":"https://gravatar.com/avatar/d3088262854661a913ef35cc40fedcc270142d4461791142bc1ea0b2a4e2e147?d=mp&s=160"},"body":"\ncvsimport creates any branches found in the remote CVS repository\nin the refs/heads namespace.  This makes sense for a repository\nconversion.  When using git as a sane interface to a remote CVS\nrepository, that repository may well remain as the 'master'\nrespository.  In this model it makes sense to import the CVS\nrepository into the refs/remotes namespace.\n\nAdd a new option '-r <remote>' to set the remote name for\nthis import.  When this option is specified branches are named\nrefs/remotes/<remote>/branch, with HEAD named as master matching\ngit-clone separate remotes layout.  Without branches are placed\nion refs/heads, with HEAD named origin as before.\n\nSigned-off-by: Andy Whitcroft <apw@shadowen.org>\n---\n\n\tGiven that separate remotes is the default for 1.5\n\tit could be argued that this the default should be the\n\tequivalent of '-r origin'.  This patch does not do that.\n---\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex f68afe7..f16ac3d 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -29,7 +29,7 @@ use IPC::Open2;\n $SIG{'PIPE'}=\"IGNORE\";\n $ENV{'TZ'}=\"UTC\";\n \n-our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a);\n+our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r);\n my (%conv_author_name, %conv_author_email);\n \n sub usage(;$) {\n@@ -114,7 +114,7 @@ sub read_repo_config {\n     }\n }\n \n-my $opts = \"haivmkuo:d:p:C:z:s:M:P:A:S:L:\";\n+my $opts = \"haivmkuo:d:p:r:C:z:s:M:P:A:S:L:\";\n read_repo_config($opts);\n getopts($opts) or usage();\n usage if $opt_h;\n@@ -134,13 +134,21 @@ if ($opt_d) {\n } else {\n \tusage(\"CVSROOT needs to be set\");\n }\n-$opt_o ||= \"origin\";\n $opt_s ||= \"-\";\n $opt_a ||= 0;\n \n my $git_tree = $opt_C;\n $git_tree ||= \".\";\n \n+my $remote;\n+if (defined $opt_r) {\n+\t$remote = 'refs/remotes/' . $opt_r;\n+\t$opt_o ||= \"master\";\n+} else {\n+\t$opt_o ||= \"origin\";\n+\t$remote = 'refs/heads';\n+}\n+\n my $cvs_tree;\n if ($#ARGV == 0) {\n \t$cvs_tree = $ARGV[0];\n@@ -522,7 +530,7 @@ sub get_headref ($$) {\n     my $name    = shift;\n     my $git_dir = shift; \n     \n-    my $f = \"$git_dir/refs/heads/$name\";\n+    my $f = \"$git_dir/$remote/$name\";\n     if (open(my $fh, $f)) {\n \t    chomp(my $r = <$fh>);\n \t    is_sha1($r) or die \"Cannot get head id for $name ($r): $!\";\n@@ -573,12 +581,12 @@ unless (-d $git_dir) {\n \n \t# Get the last import timestamps\n \tmy $fmt = '($ref, $author) = (%(refname), %(author));';\n-\topen(H, \"git-for-each-ref --perl --format='$fmt' refs/heads |\") or\n+\topen(H, \"git-for-each-ref --perl --format='$fmt' $remote |\") or\n \t\tdie \"Cannot run git-for-each-ref: $!\\n\";\n \twhile (defined(my $entry = <H>)) {\n \t\tmy ($ref, $author);\n \t\teval($entry) || die \"cannot eval refs list: $@\";\n-\t\tmy ($head) = ($ref =~ m|^refs/heads/(.*)|);\n+\t\tmy ($head) = ($ref =~ m|^$remote/(.*)|);\n \t\t$author =~ /^.*\\s(\\d+)\\s[-+]\\d{4}$/;\n \t\t$branch_date{$head} = $1;\n \t}\n@@ -701,9 +709,9 @@ sub commit {\n \t\t$index{$branch} = tmpnam();\n \t\t$ENV{GIT_INDEX_FILE} = $index{$branch};\n \t\tif ($ancestor) {\n-\t\t    system(\"git-read-tree\", $ancestor);\n+\t\t    system(\"git-read-tree\", \"$remote/$ancestor\");\n \t\t} else {\n-\t\t    system(\"git-read-tree\", $branch);\n+\t\t    system(\"git-read-tree\", \"$remote/$branch\");\n \t\t}\n \t\tdie \"read-tree failed: $?\\n\" if $?;\n \t    }\n@@ -762,7 +770,7 @@ sub commit {\n \twaitpid($pid,0);\n \tdie \"Error running git-commit-tree: $?\\n\" if $?;\n \n-\tsystem(\"git-update-ref refs/heads/$branch $cid\") == 0\n+\tsystem(\"git-update-ref $remote/$branch $cid\") == 0\n \t\tor die \"Cannot write branch $branch for update: $!\\n\";\n \n \tif ($tag) {\n@@ -883,12 +891,12 @@ while (<CVS>) {\n \t\t\t\tprint STDERR \"Branch $branch erroneously stems from itself -- changed ancestor to $opt_o\\n\";\n \t\t\t\t$ancestor = $opt_o;\n \t\t\t}\n-\t\t\tif (-f \"$git_dir/refs/heads/$branch\") {\n+\t\t\tif (-f \"$git_dir/$remote/$branch\") {\n \t\t\t\tprint STDERR \"Branch $branch already exists!\\n\";\n \t\t\t\t$state=11;\n \t\t\t\tnext;\n \t\t\t}\n-\t\t\tunless (open(H,\"$git_dir/refs/heads/$ancestor\")) {\n+\t\t\tunless (open(H,\"$git_dir/$remote/$ancestor\")) {\n \t\t\t\tprint STDERR \"Branch $ancestor does not exist!\\n\";\n \t\t\t\t$ignorebranch{$branch} = 1;\n \t\t\t\t$state=11;\n@@ -896,7 +904,7 @@ while (<CVS>) {\n \t\t\t}\n \t\t\tchomp(my $id = <H>);\n \t\t\tclose(H);\n-\t\t\tunless (open(H,\"> $git_dir/refs/heads/$branch\")) {\n+\t\t\tunless (open(H,\"> $git_dir/$remote/$branch\")) {\n \t\t\t\tprint STDERR \"Could not create branch $branch: $!\\n\";\n \t\t\t\t$ignorebranch{$branch} = 1;\n \t\t\t\t$state=11;\n@@ -1010,13 +1018,13 @@ if ($orig_branch) {\n \t\tdie \"Fast-forward update failed: $?\\n\" if $?;\n \t}\n \telse {\n-\t\tsystem(qw(git-merge cvsimport HEAD), \"refs/heads/$opt_o\");\n+\t\tsystem(qw(git-merge cvsimport HEAD), \"$remote/$opt_o\");\n \t\tdie \"Could not merge $opt_o into the current branch.\\n\" if $?;\n \t}\n } else {\n \t$orig_branch = \"master\";\n \tprint \"DONE; creating $orig_branch branch\\n\" if $opt_v;\n-\tsystem(\"git-update-ref\", \"refs/heads/master\", \"refs/heads/$opt_o\")\n+\tsystem(\"git-update-ref\", \"refs/heads/master\", \"$remote/$opt_o\")\n \t\tunless -f \"$git_dir/refs/heads/master\";\n \tsystem('git-update-ref', 'HEAD', \"$orig_branch\");\n \tunless ($opt_i) {\n"},{"id":"43636","messageId":"3f80363f0705300624w48394ed7gf7679e32670eeaa3@mail.gmail.com","threadId":"8354","inReplyTo":"3a477a76f6c5396feee452678fb8110c@pinky","subject":"Re: [PATCH] cvsimport: add support for new style remote layout","fromName":"James Bowes","fromEmail":"jbowes@dangerouslyinc.com","sentAt":"2007-05-30T13:24:46Z","receivedAt":"2007-05-30T13:24:46Z","isPatch":true,"sender":{"key":"jbowes@dangerouslyinc.com","avatar":"https://gravatar.com/avatar/a2fe98c66b2b47a9fa9d2ba92ff949d54c3208b1f8acc2e745b4b84ae3c4483a?d=mp&s=160"},"body":"On 5/29/07, Andy Whitcroft <apw@shadowen.org> wrote:\n> Add a new option '-r <remote>' to set the remote name for\n> this import.  When this option is specified branches are named\n> refs/remotes/<remote>/branch, with HEAD named as master matching\n> git-clone separate remotes layout.  Without branches are placed\n> ion refs/heads, with HEAD named origin as before.\n\nI love this. It's really nice to have 'git branch' not cluttered with\nremote branches.\n\n-James\n"},{"id":"43914","messageId":"7vvee4n1et.fsf@assigned-by-dhcp.cox.net","threadId":"8354","inReplyTo":"3a477a76f6c5396feee452678fb8110c@pinky","subject":"Re: [PATCH] cvsimport: add support for new style remote layout","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-03T22:00:58Z","receivedAt":"2007-06-03T22:00:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Whitcroft <apw@shadowen.org> writes:\n\n> cvsimport creates any branches found in the remote CVS repository\n> in the refs/heads namespace.  This makes sense for a repository\n> conversion.  When using git as a sane interface to a remote CVS\n> repository, that repository may well remain as the 'master'\n> respository.  In this model it makes sense to import the CVS\n> repository into the refs/remotes namespace.\n>\n> Add a new option '-r <remote>' to set the remote name for\n> this import.  When this option is specified branches are named\n> refs/remotes/<remote>/branch, with HEAD named as master matching\n> git-clone separate remotes layout.  Without branches are placed\n> ion refs/heads, with HEAD named origin as before.\n\nSounds good.  Docs?\n"},{"id":"43962","messageId":"4663D42A.7090201@shadowen.org","threadId":"8354","inReplyTo":"7vvee4n1et.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] cvsimport: add support for new style remote layout","fromName":"Andy Whitcroft","fromEmail":"apw@shadowen.org","sentAt":"2007-06-04T08:58:18Z","receivedAt":"2007-06-04T08:58:18Z","isPatch":true,"sender":{"key":"apw@shadowen.org","avatar":"https://gravatar.com/avatar/d3088262854661a913ef35cc40fedcc270142d4461791142bc1ea0b2a4e2e147?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Andy Whitcroft <apw@shadowen.org> writes:\n> \n>> cvsimport creates any branches found in the remote CVS repository\n>> in the refs/heads namespace.  This makes sense for a repository\n>> conversion.  When using git as a sane interface to a remote CVS\n>> repository, that repository may well remain as the 'master'\n>> respository.  In this model it makes sense to import the CVS\n>> repository into the refs/remotes namespace.\n>>\n>> Add a new option '-r <remote>' to set the remote name for\n>> this import.  When this option is specified branches are named\n>> refs/remotes/<remote>/branch, with HEAD named as master matching\n>> git-clone separate remotes layout.  Without branches are placed\n>> ion refs/heads, with HEAD named origin as before.\n> \n> Sounds good.  Docs?\n\nHeh, yep if its something wanted then it needs docs.  Will drop a couple\nof patches following this email.  The first is the documentation\nupdates.  The second adds a HEAD link matching git-clone behaviour, and\nhandily calling cvs HEAD remotes/<remote>/HEAD which seems appropriate.\n\n-apw\n"},{"id":"43963","messageId":"c0fbfa7f4c4105ab9ef61727688c46cd@pinky","threadId":"8354","inReplyTo":"4663D42A.7090201@shadowen.org","subject":"[PATCH 1/2] cvsimport: update documentation to include separate remotes option","fromName":"Andy Whitcroft","fromEmail":"apw@shadowen.org","sentAt":"2007-06-04T09:01:34Z","receivedAt":"2007-06-04T09:01:34Z","isPatch":true,"sender":{"key":"apw@shadowen.org","avatar":"https://gravatar.com/avatar/d3088262854661a913ef35cc40fedcc270142d4461791142bc1ea0b2a4e2e147?d=mp&s=160"},"body":"\nDocument the cvsimport -r <remote> option which switches cvsimport\nto using a separate remote for tracking branches.\n\nSigned-off-by: Andy Whitcroft <apw@shadowen.org>\n---\ndiff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt\nindex e0be856..4e5f1c6 100644\n--- a/Documentation/git-cvsimport.txt\n+++ b/Documentation/git-cvsimport.txt\n@@ -13,7 +13,7 @@ SYNOPSIS\n \t      [-A <author-conv-file>] [-p <options-for-cvsps>] [-P <file>]\n \t      [-C <git_repository>] [-z <fuzz>] [-i] [-k] [-u] [-s <subst>]\n \t      [-a] [-m] [-M <regex>] [-S <regex>] [-L <commitlimit>]\n-\t      [<CVS_module>]\n+\t      [-r <remote>] [<CVS_module>]\n \n \n DESCRIPTION\n@@ -25,10 +25,12 @@ Splitting the CVS log into patch sets is done by 'cvsps'.\n At least version 2.1 is required.\n \n You should *never* do any work of your own on the branches that are\n-created by git-cvsimport. The initial import will create and populate a\n+created by git-cvsimport.  By default initial import will create and populate a\n \"master\" branch from the CVS repository's main branch which you're free\n to work with; after that, you need to 'git merge' incremental imports, or\n-any CVS branches, yourself.\n+any CVS branches, yourself.  It is advisable to specify a named remote via\n+-r to separate and protect the incoming branches.\n+\n \n OPTIONS\n -------\n@@ -51,10 +53,19 @@ OPTIONS\n         The git repository to import to.  If the directory doesn't\n         exist, it will be created.  Default is the current directory.\n \n+-r <remote>::\n+\tThe git remote to import this CVS repository into.\n+\tMoves all CVS branches into remotes/<remote>/<branch>\n+\takin to the git-clone --use-separate-remote option.\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.\n-\tUse this option if you want to import into a different branch.\n+\tWhen no remote is specified (via -r) the 'HEAD' branch\n+\tfrom CVS is imported to the 'origin' branch within the git\n+\trepository, as 'HEAD' already has a special meaning for git.\n+\tWhen a remote is specified the 'HEAD' branch is named\n+\tremotes/<remote>/master mirroring git-clone behaviour.\n+\tUse this option if you want to import into a different\n+\tbranch.\n +\n Use '-o master' for continuing an import that was initially done by\n the old cvs2git tool.\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex f16ac3d..7837c7b 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -40,7 +40,7 @@ Usage: ${\\basename $0}     # fetch/update GIT from CVS\n        [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]\n        [-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z fuzz] [-i] [-k]\n        [-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit]\n-       [CVS_module]\n+       [-r remote] [CVS_module]\n END\n \texit(1);\n }\n"},{"id":"43964","messageId":"b16b1562b7ac72cee8c402b702a750b6@pinky","threadId":"8354","inReplyTo":"4663D42A.7090201@shadowen.org","subject":"[PATCH 2/2] cvsimport: add <remote>/HEAD reference in separate remotes more","fromName":"Andy Whitcroft","fromEmail":"apw@shadowen.org","sentAt":"2007-06-04T09:01:49Z","receivedAt":"2007-06-04T09:01:49Z","isPatch":true,"sender":{"key":"apw@shadowen.org","avatar":"https://gravatar.com/avatar/d3088262854661a913ef35cc40fedcc270142d4461791142bc1ea0b2a4e2e147?d=mp&s=160"},"body":"\nWhen in separate remote mode (via -r <remote>) we can now use\nthe name HEAD for the CVS HEAD.  In keeping with git-clone\nremotes/<remote>/HEAD is creates as a symbolic ref to the user\nspecified name for the HEAD which defaults to master.\n\nSigned-off-by: Andy Whitcroft <apw@shadowen.org>\n---\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 7837c7b..598b9c8 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -1026,6 +1026,8 @@ if ($orig_branch) {\n \tprint \"DONE; creating $orig_branch branch\\n\" if $opt_v;\n \tsystem(\"git-update-ref\", \"refs/heads/master\", \"$remote/$opt_o\")\n \t\tunless -f \"$git_dir/refs/heads/master\";\n+\tsystem(\"git-symbolic-ref\", \"$remote/HEAD\", \"$remote/$opt_o\")\n+\t\tif ($opt_r && $opt_o ne 'HEAD');\n \tsystem('git-update-ref', 'HEAD', \"$orig_branch\");\n \tunless ($opt_i) {\n \t\tsystem('git checkout');\n"},{"id":"44162","messageId":"1181130744.3661.7.camel@lt21223.campus.dmacc.edu","threadId":"8354","inReplyTo":"3a477a76f6c5396feee452678fb8110c@pinky","subject":"Re: [PATCH] cvsimport: add support for new style remote layout","fromName":"Jeffrey C. Ollie","fromEmail":"jeff@ocjtech.us","sentAt":"2007-06-06T11:52:24Z","receivedAt":"2007-06-06T11:52:24Z","isPatch":true,"sender":{"key":"jeff@ocjtech.us","avatar":"https://gravatar.com/avatar/95918a1992f277a811c471ae7275f7e4c9d1a2e517ad290bd6aa93b97e8d34f3?d=mp&s=160"},"body":"On Wed, 2007-05-30 at 01:56 +0100, Andy Whitcroft wrote:\n> cvsimport creates any branches found in the remote CVS repository\n> in the refs/heads namespace.  This makes sense for a repository\n> conversion.  When using git as a sane interface to a remote CVS\n> repository, that repository may well remain as the 'master'\n> respository.  In this model it makes sense to import the CVS\n> repository into the refs/remotes namespace.\n> \n> Add a new option '-r <remote>' to set the remote name for\n> this import.  When this option is specified branches are named\n> refs/remotes/<remote>/branch, with HEAD named as master matching\n> git-clone separate remotes layout.  Without branches are placed\n> ion refs/heads, with HEAD named origin as before.\n\nI've run over 5GB of cvs imports through git-cvsimport with this patch\nand it's worked very well for me...\n\nJeff\n\n"}]}