X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-svnimport.perl;h=114784ff3e2fd7329dfb1eb48470bbfc0e5fd862;hb=dff86e282fa38bf60d53b82cfa54f5f449563338;hp=86837edbdd3392ddbc6815f948132b70c0ae3458;hpb=145c9a60ad81477749a86acdf250d9e20742dcad;p=git.git diff --git a/git-svnimport.perl b/git-svnimport.perl index 86837edb..114784ff 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,10 +69,16 @@ 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*<(.+)>\s*$/; @@ -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+<(.*)>$/) { @@ -836,7 +851,7 @@ sub commit_all { $opt_l = $svn->{'maxrev'} if not defined $opt_l or $opt_l > $svn->{'maxrev'}; -if ($svn->{'maxrev'} < $current_rev) { +if ($opt_l < $current_rev) { print "Up to date: no new revisions to fetch!\n" if $opt_v; unlink("$git_dir/SVN2GIT_HEAD"); exit;