diff options
author | Junio C Hamano <junkio@cox.net> | 2006-02-27 15:48:06 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-02-27 15:48:06 -0800 |
commit | 6490603b1bb15166f4f912f04f20b0c84d6114af (patch) | |
tree | eef393ceb969ff83eb97297c1554af20ec17d690 | |
parent | 6c1413a17e38ecd906e186c7679d2db6d016a3cb (diff) | |
parent | d3cac2c95a1600c9269c821153cbad681b66a8d2 (diff) | |
download | git-6490603b1bb15166f4f912f04f20b0c84d6114af.tar.gz git-6490603b1bb15166f4f912f04f20b0c84d6114af.tar.xz |
Merge branch 'kh/svnimport' into next
* kh/svnimport:
Save username -> Full Name <email@addr.es> map file
Let git-svnimport's author file use same syntax as git-cvsimport's
-rw-r--r-- | Documentation/git-svnimport.txt | 9 | ||||
-rwxr-xr-x | git-svnimport.perl | 27 |
2 files changed, 28 insertions, 8 deletions
diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt index e0e3a5d4e..a1588138e 100644 --- a/Documentation/git-svnimport.txt +++ b/Documentation/git-svnimport.txt @@ -75,13 +75,18 @@ When importing incrementally, you might need to edit the .git/svn2git file. -A <author_file>:: Read a file with lines on the form - username User's Full Name <email@addres.org> + username = User's Full Name <email@addr.es> - and use "User's Full Name <email@addres.org>" as the GIT + and use "User's Full Name <email@addr.es>" as the GIT author and committer for Subversion commits made by "username". If encountering a commit made by a user not in the list, abort. + For convenience, this data is saved to $GIT_DIR/svn-authors + each time the -A option is provided, and read from that same + file each time git-svnimport is run with an existing GIT + repository without -A. + -m:: Attempt to detect merges based on the commit message. This option will enable default regexes that try to capture the name source diff --git a/git-svnimport.perl b/git-svnimport.perl index 75ce8e068..639aa4186 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -13,6 +13,7 @@ use strict; use warnings; use Getopt::Std; +use File::Copy; use File::Spec; use File::Temp qw(tempfile); use File::Path qw(mkpath); @@ -68,13 +69,19 @@ if ($opt_M) { push (@mergerx, qr/$opt_M/); } +# Absolutize filename now, since we will have chdir'ed by the time we +# get around to opening it. +$opt_A = File::Spec->rel2abs($opt_A) if $opt_A; + our %users = (); -if ($opt_A) { - die "Cannot open $opt_A\n" unless -f $opt_A; - open(my $authors,$opt_A); +our $users_file = undef; +sub read_users($) { + $users_file = File::Spec->rel2abs(@_); + die "Cannot open $users_file\n" unless -f $users_file; + open(my $authors,$users_file); while(<$authors>) { chomp; - next unless /^(\S+)\s+(.+?)\s+<(\S+)>$/; + next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/; (my $user,my $name,my $email) = ($1,$2,$3); $users{$user} = [$name,$email]; } @@ -302,6 +309,14 @@ EOM -d $git_dir or die "Could not create git subdir ($git_dir).\n"; +my $default_authors = "$git_dir/svn-authors"; +if ($opt_A) { + read_users($opt_A); + copy($opt_A,$default_authors) or die "Copy failed: $!"; +} else { + read_users($default_authors) if -f $default_authors; +} + open BRANCHES,">>", "$git_dir/svn2git"; sub node_kind($$$) { @@ -498,8 +513,8 @@ sub commit { if (not defined $author) { $author_name = $author_email = "unknown"; - } elsif ($opt_A) { - die "User $author is not listed in $opt_A\n" + } elsif (defined $users_file) { + die "User $author is not listed in $users_file\n" unless exists $users{$author}; ($author_name,$author_email) = @{$users{$author}}; } elsif ($author =~ /^(.*?)\s+<(.*)>$/) { |