Skip to content

Commit 8cd1621

Browse files
author
Junio C Hamano
committed
cvsimport: ease migration from CVSROOT/users format
This fixes a minor bug, which caused the author email to be doubly enclosed in a <> pair (the code gave enclosing <> to GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL environment variable). The read_author_info() subroutine is taught to also understand the user list in CVSROOT/users format. This is primarily done to ease migration for CVS users, who can use the -A option to read from existing CVSROOT/users file. write_author_info() always writes in the git-cvsimport's native format ('=' delimited and value without quotes). Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent ffd97f3 commit 8cd1621

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

git-cvsimport.perl

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,28 @@ ($)
4848
open my $f, '<', "$file" or die("Failed to open $file: $!\n");
4949

5050
while (<$f>) {
51-
chomp;
52-
# Expected format is this;
51+
# Expected format is this:
5352
# exon=Andreas Ericsson <ae@op5.se>
54-
if (m/^([^ \t=]*)[ \t=]*([^<]*)(<.*$)\s*/) {
53+
if (m/^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/) {
5554
$user = $1;
56-
$conv_author_name{$1} = $2;
57-
$conv_author_email{$1} = $3;
58-
# strip trailing whitespace from author name
59-
$conv_author_name{$1} =~ s/\s*$//;
55+
$conv_author_name{$user} = $2;
56+
$conv_author_email{$user} = $3;
6057
}
58+
# However, we also read from CVSROOT/users format
59+
# to ease migration.
60+
elsif (/^(\w+):(['"]?)(.+?)\2\s*$/) {
61+
my $mapped;
62+
($user, $mapped) = ($1, $3);
63+
if ($mapped =~ /^\s*(.*?)\s*<(.*)>\s*$/) {
64+
$conv_author_name{$user} = $1;
65+
$conv_author_email{$user} = $2;
66+
}
67+
elsif ($mapped =~ /^<?(.*)>?$/) {
68+
$conv_author_name{$user} = $user;
69+
$conv_author_email{$user} = $1;
70+
}
71+
}
72+
# NEEDSWORK: Maybe warn on unrecognized lines?
6173
}
6274
close ($f);
6375
}
@@ -68,8 +80,7 @@ ($)
6880
die("Failed to open $file for writing: $!");
6981

7082
foreach (keys %conv_author_name) {
71-
print $f "$_=" . $conv_author_name{$_} .
72-
" " . $conv_author_email{$_} . "\n";
83+
print $f "$_=$conv_author_name{$_} <$conv_author_email{$_}>\n";
7384
}
7485
close ($f);
7586
}

0 commit comments

Comments
 (0)