summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 80804d0)
raw | patch | inline | side by side (parent: 80804d0)
author | Karl Hasselström <kha@treskal.com> | |
Mon, 27 Feb 2006 23:08:19 +0000 (00:08 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 27 Feb 2006 23:27:24 +0000 (15:27 -0800) |
When the user specifies a username -> Full Name <email@addr.es> map
file with the -A option, save a copy of that file as
$git_dir/svn-authors. When running git-svnimport with an existing GIT
directory, use $git_dir/svn-authors (if it exists) unless a file was
explicitly specified with -A.
Signed-off-by: Karl Hasselström <kha@treskal.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
file with the -A option, save a copy of that file as
$git_dir/svn-authors. When running git-svnimport with an existing GIT
directory, use $git_dir/svn-authors (if it exists) unless a file was
explicitly specified with -A.
Signed-off-by: Karl Hasselström <kha@treskal.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-svnimport.txt | patch | blob | history | |
git-svnimport.perl | patch | blob | history |
index 912a80865e7616fc81905616f9b9f86c531ff4ce..a1588138ea5887e9aa785a21481cc29e790f6dab 100644 (file)
"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 86837edbdd3392ddbc6815f948132b70c0ae3458..639aa41861a734aab225479be7524c972191da70 100755 (executable)
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
use strict;
use warnings;
use Getopt::Std;
+use File::Copy;
use File::Spec;
use File::Temp qw(tempfile);
use File::Path qw(mkpath);
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*<(.+)>\s*$/;
-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($$$) {
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+<(.*)>$/) {