{"thread":{"id":"5488","subject":"[PATCH] git-svnimport: Parse log message for Signed-off-by: lines","startedAt":"2006-09-05T18:46:11Z","lastAt":"2006-09-28T19:44:57Z","messageCount":7,"participants":["Sasha Khapyorsky","Junio C Hamano","Matthias Urlichs"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"26365","messageId":"20060905184611.GB14732@sashak.voltaire.com","threadId":"5488","inReplyTo":null,"subject":"[PATCH] git-svnimport: Parse log message for Signed-off-by: lines","fromName":"Sasha Khapyorsky","fromEmail":"sashak@voltaire.com","sentAt":"2006-09-05T18:46:11Z","receivedAt":"2006-09-05T18:46:11Z","isPatch":true,"sender":{"key":"sashak@voltaire.com","avatar":null},"body":"Hi,\n\nThis feature was useful with importing https://openib.org/svn/gen2 .\n\nSasha\n\nThis add '-S' option. When specified svn-import will try to parse\ncommit message for 'Signed-off-by: ...' line, and if found will use\nthe name and email address extracted at first occurrence as this commit\nauthor name and author email address. Committer name and email are\nextracted in usual way.\n\nSigned-off-by: Sasha Khapyorsky <sashak@voltaire.com>\n---\n git-svnimport.perl |   31 ++++++++++++++++++++-----------\n 1 files changed, 20 insertions(+), 11 deletions(-)\n\ndiff --git a/git-svnimport.perl b/git-svnimport.perl\nindex 26dc454..7113cf5 100755\n--- a/git-svnimport.perl\n+++ b/git-svnimport.perl\n@@ -31,7 +31,7 @@ die \"Need SVN:Core 1.2.1 or better\" if $\n $ENV{'TZ'}=\"UTC\";\n \n our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,\n-    $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D);\n+    $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D,$opt_S);\n \n sub usage() {\n \tprint STDERR <<END;\n@@ -39,12 +39,12 @@ Usage: ${\\basename $0}     # fetch/updat\n        [-o branch-for-HEAD] [-h] [-v] [-l max_rev]\n        [-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]\n        [-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]\n-       [-m] [-M regex] [-A author_file] [SVN_URL]\n+       [-m] [-M regex] [-A author_file] [-S] [SVN_URL]\n END\n \texit(1);\n }\n \n-getopts(\"A:b:C:dDhiI:l:mM:o:rs:t:T:uv\") or usage();\n+getopts(\"A:b:C:dDhiI:l:mM:o:rs:t:T:Suv\") or usage();\n usage if $opt_h;\n \n my $tag_name = $opt_t || \"tags\";\n@@ -531,21 +531,30 @@ sub copy_path($$$$$$$$) {\n \n sub commit {\n \tmy($branch, $changed_paths, $revision, $author, $date, $message) = @_;\n-\tmy($author_name,$author_email,$dest);\n+\tmy($committer_name,$committer_email,$dest);\n+\tmy($author_name,$author_email);\n \tmy(@old,@new,@parents);\n \n \tif (not defined $author or $author eq \"\") {\n-\t\t$author_name = $author_email = \"unknown\";\n+\t\t$committer_name = $committer_email = \"unknown\";\n \t} elsif (defined $users_file) {\n \t\tdie \"User $author is not listed in $users_file\\n\"\n \t\t    unless exists $users{$author};\n-\t\t($author_name,$author_email) = @{$users{$author}};\n+\t\t($committer_name,$committer_email) = @{$users{$author}};\n \t} elsif ($author =~ /^(.*?)\\s+<(.*)>$/) {\n-\t\t($author_name, $author_email) = ($1, $2);\n+\t\t($committer_name, $committer_email) = ($1, $2);\n \t} else {\n \t\t$author =~ s/^<(.*)>$/$1/;\n-\t\t$author_name = $author_email = $author;\n+\t\t$committer_name = $committer_email = $author;\n \t}\n+\n+\tif ($opt_S && $message =~ /Signed-off-by:\\s+(.*?)\\s+<(.*)>\\s*\\n/) {\n+        \t($author_name, $author_email) = ($1, $2);\n+\t} else {\n+\t\t$author_name = $committer_name;\n+\t\t$author_email = $committer_email;\n+\t}\n+\n \t$date = pdate($date);\n \n \tmy $tag;\n@@ -772,8 +781,8 @@ #\t}\n \t\t\t\t\"GIT_AUTHOR_NAME=$author_name\",\n \t\t\t\t\"GIT_AUTHOR_EMAIL=$author_email\",\n \t\t\t\t\"GIT_AUTHOR_DATE=\".strftime(\"+0000 %Y-%m-%d %H:%M:%S\",gmtime($date)),\n-\t\t\t\t\"GIT_COMMITTER_NAME=$author_name\",\n-\t\t\t\t\"GIT_COMMITTER_EMAIL=$author_email\",\n+\t\t\t\t\"GIT_COMMITTER_NAME=$committer_name\",\n+\t\t\t\t\"GIT_COMMITTER_EMAIL=$committer_email\",\n \t\t\t\t\"GIT_COMMITTER_DATE=\".strftime(\"+0000 %Y-%m-%d %H:%M:%S\",gmtime($date)),\n \t\t\t\t\"git-commit-tree\", $tree,@par);\n \t\t\tdie \"Cannot exec git-commit-tree: $!\\n\";\n@@ -825,7 +834,7 @@ #\t}\n \t\tprint $out (\"object $cid\\n\".\n \t\t    \"type commit\\n\".\n \t\t    \"tag $dest\\n\".\n-\t\t    \"tagger $author_name <$author_email>\\n\") and\n+\t\t    \"tagger $committer_name <$committer_email>\\n\") and\n \t\tclose($out)\n \t\t    or die \"Cannot create tag object $dest: $!\\n\";\n \n-- \n1.4.2\n"},{"id":"26371","messageId":"7v1wqqc8dh.fsf@assigned-by-dhcp.cox.net","threadId":"5488","inReplyTo":"20060905184611.GB14732@sashak.voltaire.com","subject":"Re: [PATCH] git-svnimport: Parse log message for Signed-off-by: lines","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-05T21:26:50Z","receivedAt":"2006-09-05T21:26:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sasha Khapyorsky <sashak@voltaire.com> writes:\n\n> Hi,\n>\n> This feature was useful with importing https://openib.org/svn/gen2 .\n>\n> Sasha\n>\n> This add '-S' option. When specified svn-import will try to parse\n> commit message for 'Signed-off-by: ...' line, and if found will use\n> the name and email address extracted at first occurrence as this commit\n> author name and author email address. Committer name and email are\n> extracted in usual way.\n>\n> Signed-off-by: Sasha Khapyorsky <sashak@voltaire.com>\n\nThanks.\n\nI do not think the first signed-off-by is necessarily the author\nof the change, so we are risking miscrediting (or misblaming) a\nwrong person.  Having said that, using the committer information\nhas the same miscredit problem, so this change might be Ok, but\nI am not sure if it adds much improvement.\n\nI will wait for an ack/nack from somebody who use svnimport and\nknow it well.\n\nBTW, I do not appreciate the first six lines of your message\nbeing _before_ the proposed commit log message.  Please have it\nbetween \"---\\n\" (that comes immediately after your own\n\"Signed-off-by:\") and the diffstat, like this:\n\n        This add '-S' option. When specified svn-import will try to...\n        ... in usual way.\n\n        Signed-off-by: Sasha Khapyorsky <sashak@voltaire.com>\n        ---\n\n          Hi,\n\n          This feature was useful with importing https://openib.org/svn/gen2 .\n\n          Sasha\n\n         git-svnimport.perl |   31 ++++++++++++++++++++-----------\n         1 files changed, 20 insertions(+), 11 deletions(-)\n\n         diff --git a/...\n"},{"id":"26379","messageId":"20060905221754.GI14732@sashak.voltaire.com","threadId":"5488","inReplyTo":"7v1wqqc8dh.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-svnimport: Parse log message for Signed-off-by: lines","fromName":"Sasha Khapyorsky","fromEmail":"sashak@voltaire.com","sentAt":"2006-09-05T22:17:54Z","receivedAt":"2006-09-05T22:17:54Z","isPatch":true,"sender":{"key":"sashak@voltaire.com","avatar":null},"body":"On 14:26 Tue 05 Sep     , Junio C Hamano wrote:\n> Sasha Khapyorsky <sashak@voltaire.com> writes:\n> \n> > Hi,\n> >\n> > This feature was useful with importing https://openib.org/svn/gen2 .\n> >\n> > Sasha\n> >\n> > This add '-S' option. When specified svn-import will try to parse\n> > commit message for 'Signed-off-by: ...' line, and if found will use\n> > the name and email address extracted at first occurrence as this commit\n> > author name and author email address. Committer name and email are\n> > extracted in usual way.\n> >\n> > Signed-off-by: Sasha Khapyorsky <sashak@voltaire.com>\n> \n> Thanks.\n> \n> I do not think the first signed-off-by is necessarily the author\n> of the change, so we are risking miscrediting (or misblaming) a\n> wrong person. \n\nRight, there is such risk, so this feature is optional and by default is\n\"off\".\n\n> Having said that, using the committer information\n> has the same miscredit problem, so this change might be Ok, but\n> I am not sure if it adds much improvement.\n> \n> I will wait for an ack/nack from somebody who use svnimport and\n> know it well.\n\nSure.\n\nBTW, what about to importing subdirectories, like this:\n\n <trunk>/path/to/subdir\n <branches>/path/to/subdir\n\nIs this could be improvement?\n\n> \n> BTW, I do not appreciate the first six lines of your message\n> being _before_ the proposed commit log message.  Please have it\n> between \"---\\n\" (that comes immediately after your own\n> \"Signed-off-by:\") and the diffstat, like this:\n> \n>         This add '-S' option. When specified svn-import will try to...\n>         ... in usual way.\n> \n>         Signed-off-by: Sasha Khapyorsky <sashak@voltaire.com>\n>         ---\n> \n>           Hi,\n> \n>           This feature was useful with importing https://openib.org/svn/gen2 .\n> \n>           Sasha\n> \n>          git-svnimport.perl |   31 ++++++++++++++++++++-----------\n>          1 files changed, 20 insertions(+), 11 deletions(-)\n> \n>          diff --git a/...\n\nOk.\n\nSasha\n"},{"id":"26381","messageId":"7v8xkxc2tr.fsf@assigned-by-dhcp.cox.net","threadId":"5488","inReplyTo":"20060905221754.GI14732@sashak.voltaire.com","subject":"Re: [PATCH] git-svnimport: Parse log message for Signed-off-by: lines","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-05T23:26:40Z","receivedAt":"2006-09-05T23:26:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sasha Khapyorsky <sashak@voltaire.com> writes:\n\n> BTW, what about to importing subdirectories, like this:\n>\n>  <trunk>/path/to/subdir\n>  <branches>/path/to/subdir\n>\n> Is this could be improvement?\n\nI somehow had an impression that svnimport dealt with the\nreversed layout already, although $project/{trunk,branches,tags}\nlayout is assumed by default; maybe I was mistaken.\n\nIf the tool can automatically detect the layout the remote\nproject employs, and adjust the default accordingly, I would\nimagine that would be a useful addition.\n"},{"id":"26403","messageId":"20060906125317.GA21645@sashak.voltaire.com","threadId":"5488","inReplyTo":"7v8xkxc2tr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-svnimport: Parse log message for Signed-off-by: lines","fromName":"Sasha Khapyorsky","fromEmail":"sashak@voltaire.com","sentAt":"2006-09-06T12:53:17Z","receivedAt":"2006-09-06T12:53:17Z","isPatch":true,"sender":{"key":"sashak@voltaire.com","avatar":null},"body":"On 16:26 Tue 05 Sep     , Junio C Hamano wrote:\n> Sasha Khapyorsky <sashak@voltaire.com> writes:\n> \n> > BTW, what about to importing subdirectories, like this:\n> >\n> >  <trunk>/path/to/subdir\n> >  <branches>/path/to/subdir\n> >\n> > Is this could be improvement?\n> \n> I somehow had an impression that svnimport dealt with the\n> reversed layout already, although $project/{trunk,branches,tags}\n> layout is assumed by default; maybe I was mistaken.\n\nAt least I didn't succeed with reversed layout. With option\n-T <trunk>/$project import works but only for trunk branch, attempts\nto specify branch as -b <branches> or -b <branches>/$project don't help,\nthe same is with tags.\n\n> If the tool can automatically detect the layout the remote\n> project employs, and adjust the default accordingly, I would\n> imagine that would be a useful addition.\n\nNot really automatically, but $project may be passed as option argument\nin command line (let's say -p or -P), then git-svnimport will attempt to\nparse such SVN repo layout:\n\n  <trunk>/$project\n  <branches>/<names>/$project\n  ...\n\nI will verify the patch (it worked only once with our specific project -\nOpenSM) and then will post.\n\nSasha\n"},{"id":"26418","messageId":"20060906153314.GE6999@kiste.smurf.noris.de","threadId":"5488","inReplyTo":"20060906125317.GA21645@sashak.voltaire.com","subject":"Re: [PATCH] git-svnimport: Parse log message for Signed-off-by: lines","fromName":"Matthias Urlichs","fromEmail":"smurf@smurf.noris.de","sentAt":"2006-09-06T15:33:14Z","receivedAt":"2006-09-06T15:33:14Z","isPatch":true,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Hi,\n\nSasha Khapyorsky:\n> At least I didn't succeed with reversed layout. With option\n> -T <trunk>/$project import works but only for trunk branch, attempts\n> to specify branch as -b <branches> or -b <branches>/$project don't help,\n> the same is with tags.\n> \nThat's true. The problem is that it wants the tag or branch name as the\nlast component of the path.\n\nA more generic solution would be to use wildcards in the branch/tag\nspecification, to allow more than one wildcard, and to be able to\nspecify the exact form of the branch or tag name on the git side.\n\nAll of this should be specified in the repository's git config file,\nnot on the command line.\n\n\nSomebody who wants to implement that is certainly invited to do so.\n(I don't have time for that at the moment, unfortunately.)\n\n-- \nMatthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de\n"},{"id":"27925","messageId":"20060928194457.GE10617@sashak.voltaire.com","threadId":"5488","inReplyTo":"20060906153314.GE6999@kiste.smurf.noris.de","subject":"partial svnimport [was: Re: [PATCH] git-svnimport: Parse log message for Signed-off-by: lines]","fromName":"Sasha Khapyorsky","fromEmail":"sashak@voltaire.com","sentAt":"2006-09-28T19:44:57Z","receivedAt":"2006-09-28T19:44:57Z","isPatch":true,"sender":{"key":"sashak@voltaire.com","avatar":null},"body":"Hi,\n\nOn 17:33 Wed 06 Sep     , Matthias Urlichs wrote:\n> Hi,\n> \n> Sasha Khapyorsky:\n> > At least I didn't succeed with reversed layout. With option\n> > -T <trunk>/$project import works but only for trunk branch, attempts\n> > to specify branch as -b <branches> or -b <branches>/$project don't help,\n> > the same is with tags.\n> > \n> That's true. The problem is that it wants the tag or branch name as the\n> last component of the path.\n> \n> A more generic solution would be to use wildcards in the branch/tag\n> specification, to allow more than one wildcard, and to be able to\n> specify the exact form of the branch or tag name on the git side.\n\nOr perhaps just to specify path of the project (or sub-project) after\ntrunk/branches*/ . Like in this patch:\n\n\ndiff --git a/git-svnimport.perl b/git-svnimport.perl\nindex 988514e..86a6e8a 100755\n--- a/git-svnimport.perl\n+++ b/git-svnimport.perl\n@@ -31,7 +31,8 @@ die \"Need SVN:Core 1.2.1 or better\" if $\n $ENV{'TZ'}=\"UTC\";\n \n our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,\n-    $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D,$opt_S,$opt_F);\n+    $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D,$opt_S,$opt_F,\n+    $opt_P);\n \n sub usage() {\n \tprint STDERR <<END;\n@@ -39,17 +40,19 @@ Usage: ${\\basename $0}     # fetch/updat\n        [-o branch-for-HEAD] [-h] [-v] [-l max_rev]\n        [-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]\n        [-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]\n-       [-m] [-M regex] [-A author_file] [-S] [-F] [SVN_URL]\n+       [-m] [-M regex] [-A author_file] [-S] [-F] [-P project] [SVN_URL]\n END\n \texit(1);\n }\n \n-getopts(\"A:b:C:dDFhiI:l:mM:o:rs:t:T:Suv\") or usage();\n+getopts(\"A:b:C:dDFhiI:l:mM:o:rs:t:T:SP:uv\") or usage();\n usage if $opt_h;\n \n my $tag_name = $opt_t || \"tags\";\n my $trunk_name = $opt_T || \"trunk\";\n my $branch_name = $opt_b || \"branches\";\n+my $project_name = $opt_P || \"\";\n+$project_name = \"/\" . $project_name if ($project_name);\n \n @ARGV == 1 or @ARGV == 2 or usage();\n \n@@ -356,11 +359,11 @@ sub revert_split_path($$) {\n \tmy $svnpath;\n \t$path = \"\" if $path eq \"/\"; # this should not happen, but ...\n \tif($branch eq \"/\") {\n-\t\t$svnpath = \"$trunk_name/$path\";\n+\t\t$svnpath = \"$trunk_name$project_name/$path\";\n \t} elsif($branch =~ m#^/#) {\n-\t\t$svnpath = \"$tag_name$branch/$path\";\n+\t\t$svnpath = \"$tag_name$branch$project_name/$path\";\n \t} else {\n-\t\t$svnpath = \"$branch_name/$branch/$path\";\n+\t\t$svnpath = \"$branch_name/$branch$project_name/$path\";\n \t}\n \n \t$svnpath =~ s#/+$##;\n@@ -864,6 +867,20 @@ #\t}\n \tprint \"DONE: $revision $dest $cid\\n\" if $opt_v;\n }\n \n+sub project_path($$)\n+{\n+\tmy ($path, $project) = @_;\n+\n+\t$path = \"/\".$path unless ($path =~ m#^\\/#) ;\n+\treturn $1 if ($path =~ m#^$project\\/(.*)$#);\n+\n+\t$path =~ s#\\.#\\\\\\.#g;\n+\t$path =~ s#\\+#\\\\\\+#g;\n+\treturn \"/\" if ($project =~ m#^$path.*$#);\n+\n+\treturn undef;\n+}\n+\n sub commit_all {\n \t# Recursive use of the SVN connection does not work\n \tlocal $svn = $svn2;\n@@ -883,6 +900,10 @@ sub commit_all {\n \twhile(my($path,$action) = each %$changed_paths) {\n \t\t($branch,$path) = split_path($revision,$path);\n \t\tnext if not defined $branch;\n+\t\tif ($project_name) {\n+\t\t\t$path = project_path($path, $project_name);\n+\t\t\tnext if not defined $path;\n+\t\t}\n \t\t$done{$branch}{$path} = $action;\n \t}\n \twhile(($branch,$changed_paths) = each %done) {\n\n\n(will submit if above is acceptable)\n\n> All of this should be specified in the repository's git config file,\n> not on the command line.\n\nIt is for incremental imports? So we will not need to reproduce exact\ncommand line for each git-svnimport run? Good idea.\n\nSasha\n"}]}