{"thread":{"id":"3075","subject":"[PATCH] cvsimport: ease migration from CVSROOT/users format","startedAt":"2006-01-15T11:30:30Z","lastAt":"2006-01-15T20:50:22Z","messageCount":2,"participants":["Junio C Hamano","Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"14683","messageId":"7vbqyd684p.fsf@assigned-by-dhcp.cox.net","threadId":"3075","inReplyTo":null,"subject":"[PATCH] cvsimport: ease migration from CVSROOT/users format","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-15T11:30:30Z","receivedAt":"2006-01-15T11:30:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This fixes a minor bug, which caused the author email to be\ndoubly enclosed in a <> pair (the code gave enclosing <> to\nGIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL environment variable).\n\nThe read_author_info() subroutine is taught to also understand\nthe user list in CVSROOT/users format.  This is primarily done\nto ease migration for CVS users, who can use the -A option\nto read from existing CVSROOT/users file.  write_author_info()\nalways writes in the git-cvsimport's native format ('='\ndelimited and value without quotes).\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * Andreas, I also tweaked the regexp to parse the native format\n   from /^([^ \\t=]*)[ \\t=]*([^<]*)(<.*$)\\s*/\n   to /^(\\S+?)\\s*=\\s*(.+?)\\s*<(.+)>\\s*$/.  I think this tweak is\n   correct, but I would appreciate if you can proofread and ACK\n   on it.  The differences are:\n\n   - We did not require '=' anywhere, but accepted \"= = =\".\n   - We had funny '$' in the middle; probably a typo. \n   - We first slurped author name with trailing whitespaces, only \n     to strip that separately in later steps.\n   - We grabbed <> pairs and stored in author_email (this is a\n     bugfix).\n\n git-cvsimport.perl |   29 ++++++++++++++++++++---------\n 1 files changed, 20 insertions(+), 9 deletions(-)\n\n1b23ed3d1f9f3d83ea8b94ebc37c99e0ca32a09b\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8d493c2..3ddbdfa 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -48,16 +48,28 @@ sub read_author_info($) {\n \topen my $f, '<', \"$file\" or die(\"Failed to open $file: $!\\n\");\n \n \twhile (<$f>) {\n-\t\tchomp;\n-\t\t# Expected format is this;\n+\t\t# Expected format is this:\n \t\t#   exon=Andreas Ericsson <ae@op5.se>\n-\t\tif (m/^([^ \\t=]*)[ \\t=]*([^<]*)(<.*$)\\s*/) {\n+\t\tif (m/^(\\S+?)\\s*=\\s*(.+?)\\s*<(.+)>\\s*$/) {\n \t\t\t$user = $1;\n-\t\t\t$conv_author_name{$1} = $2;\n-\t\t\t$conv_author_email{$1} = $3;\n-\t\t\t# strip trailing whitespace from author name\n-\t\t\t$conv_author_name{$1} =~ s/\\s*$//;\n+\t\t\t$conv_author_name{$user} = $2;\n+\t\t\t$conv_author_email{$user} = $3;\n \t\t}\n+\t\t# However, we also read from CVSROOT/users format\n+\t\t# to ease migration.\n+\t\telsif (/^(\\w+):(['\"]?)(.+?)\\2\\s*$/) {\n+\t\t\tmy $mapped;\n+\t\t\t($user, $mapped) = ($1, $3);\n+\t\t\tif ($mapped =~ /^\\s*(.*?)\\s*<(.*)>\\s*$/) {\n+\t\t\t\t$conv_author_name{$user} = $1;\n+\t\t\t\t$conv_author_email{$user} = $2;\n+\t\t\t}\n+\t\t\telsif ($mapped =~ /^<?(.*)>?$/) {\n+\t\t\t\t$conv_author_name{$user} = $user;\n+\t\t\t\t$conv_author_email{$user} = $1;\n+\t\t\t}\n+\t\t}\n+\t\t# NEEDSWORK: Maybe warn on unrecognized lines?\n \t}\n \tclose ($f);\n }\n@@ -68,8 +80,7 @@ sub write_author_info($) {\n \t  die(\"Failed to open $file for writing: $!\");\n \n \tforeach (keys %conv_author_name) {\n-\t\tprint $f \"$_=\" . $conv_author_name{$_} .\n-\t\t  \" \" . $conv_author_email{$_} . \"\\n\";\n+\t\tprint $f \"$_=$conv_author_name{$_} <$conv_author_email{$_}>\\n\";\n \t}\n \tclose ($f);\n }\n-- \n1.1.2-gd425\n"},{"id":"14694","messageId":"43CAB58E.7090707@op5.se","threadId":"3075","inReplyTo":"7vbqyd684p.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] cvsimport: ease migration from CVSROOT/users format","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-01-15T20:50:22Z","receivedAt":"2006-01-15T20:50:22Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> \n>  * Andreas, I also tweaked the regexp to parse the native format\n>    from /^([^ \\t=]*)[ \\t=]*([^<]*)(<.*$)\\s*/\n>    to /^(\\S+?)\\s*=\\s*(.+?)\\s*<(.+)>\\s*$/.  I think this tweak is\n>    correct, but I would appreciate if you can proofread and ACK\n>    on it.  The differences are:\n> \n\nIt looks correct and seems to do the trick.\n\n\n>    - We grabbed <> pairs and stored in author_email (this is a\n>      bugfix).\n> \n\ngitk showed them as a single such even though theye were passed double. \nPerhaps some other tool stripped it along the way? Good catch anyways.\n\n> +\t\t}\n> +\t\t# NEEDSWORK: Maybe warn on unrecognized lines?\n>  \t}\n\nI don't think so. I think it's safe to assume that people will check and \ndouble-check that everything's correct before removing the CVS repo, so \nit should be easy enough to redo the import (although possibly \ntime-consuming).\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"}]}