Skip to content

Commit 5343cf1

Browse files
author
Junio C Hamano
committed
Merge branch 'kh/svnimport'
* kh/svnimport: Save username -> Full Name <email@addr.es> map file
2 parents b6b626f + d3cac2c commit 5343cf1

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

Documentation/git-svnimport.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ When importing incrementally, you might need to edit the .git/svn2git file.
8282
"username". If encountering a commit made by a user not in the
8383
list, abort.
8484

85+
For convenience, this data is saved to $GIT_DIR/svn-authors
86+
each time the -A option is provided, and read from that same
87+
file each time git-svnimport is run with an existing GIT
88+
repository without -A.
89+
8590
-m::
8691
Attempt to detect merges based on the commit message. This option
8792
will enable default regexes that try to capture the name source

git-svnimport.perl

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use strict;
1414
use warnings;
1515
use Getopt::Std;
16+
use File::Copy;
1617
use File::Spec;
1718
use File::Temp qw(tempfile);
1819
use File::Path qw(mkpath);
@@ -68,10 +69,16 @@ END
6869
push (@mergerx, qr/$opt_M/);
6970
}
7071

72+
# Absolutize filename now, since we will have chdir'ed by the time we
73+
# get around to opening it.
74+
$opt_A = File::Spec->rel2abs($opt_A) if $opt_A;
75+
7176
our %users = ();
72-
if ($opt_A) {
73-
die "Cannot open $opt_A\n" unless -f $opt_A;
74-
open(my $authors,$opt_A);
77+
our $users_file = undef;
78+
sub read_users($) {
79+
$users_file = File::Spec->rel2abs(@_);
80+
die "Cannot open $users_file\n" unless -f $users_file;
81+
open(my $authors,$users_file);
7582
while(<$authors>) {
7683
chomp;
7784
next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
@@ -302,6 +309,14 @@ ($$)
302309
-d $git_dir
303310
or die "Could not create git subdir ($git_dir).\n";
304311

312+
my $default_authors = "$git_dir/svn-authors";
313+
if ($opt_A) {
314+
read_users($opt_A);
315+
copy($opt_A,$default_authors) or die "Copy failed: $!";
316+
} else {
317+
read_users($default_authors) if -f $default_authors;
318+
}
319+
305320
open BRANCHES,">>", "$git_dir/svn2git";
306321

307322
sub node_kind($$$) {
@@ -498,8 +513,8 @@ sub commit {
498513

499514
if (not defined $author) {
500515
$author_name = $author_email = "unknown";
501-
} elsif ($opt_A) {
502-
die "User $author is not listed in $opt_A\n"
516+
} elsif (defined $users_file) {
517+
die "User $author is not listed in $users_file\n"
503518
unless exists $users{$author};
504519
($author_name,$author_email) = @{$users{$author}};
505520
} elsif ($author =~ /^(.*?)\s+<(.*)>$/) {

0 commit comments

Comments
 (0)