Skip to content

Commit f3a4ec4

Browse files
author
Junio C Hamano
committed
Merge part of kh/svnimport branch into master
2 parents 7be7376 + 80804d0 commit f3a4ec4

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

Documentation/git-svnimport.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ SYNOPSIS
1313
[ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_rev]
1414
[ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
1515
[ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
16-
[ -I <ignorefile_name> ] <SVN_repository_URL> [ <path> ]
16+
[ -I <ignorefile_name> ] [ -A <author_file> ]
17+
<SVN_repository_URL> [ <path> ]
1718

1819

1920
DESCRIPTION
@@ -71,6 +72,16 @@ When importing incrementally, you might need to edit the .git/svn2git file.
7172
syntaxes are similar enough that using the Subversion patterns
7273
directly with "-I .gitignore" will almost always just work.)
7374

75+
-A <author_file>::
76+
Read a file with lines on the form
77+
78+
username = User's Full Name <email@addr.es>
79+
80+
and use "User's Full Name <email@addr.es>" as the GIT
81+
author and committer for Subversion commits made by
82+
"username". If encountering a commit made by a user not in the
83+
list, abort.
84+
7485
-m::
7586
Attempt to detect merges based on the commit message. This option
7687
will enable default regexes that try to capture the name source

git-svnimport.perl

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@
3030
$ENV{'TZ'}="UTC";
3131

3232
our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,
33-
$opt_b,$opt_r,$opt_I,$opt_s,$opt_l,$opt_d,$opt_D);
33+
$opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D);
3434

3535
sub usage() {
3636
print STDERR <<END;
3737
Usage: ${\basename $0} # fetch/update GIT from SVN
3838
[-o branch-for-HEAD] [-h] [-v] [-l max_rev]
3939
[-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
4040
[-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]
41-
[-m] [-M regex] [SVN_URL]
41+
[-m] [-M regex] [-A author_file] [SVN_URL]
4242
END
4343
exit(1);
4444
}
4545

46-
getopts("b:C:dDhiI:l:mM:o:rs:t:T:uv") or usage();
46+
getopts("A:b:C:dDhiI:l:mM:o:rs:t:T:uv") or usage();
4747
usage if $opt_h;
4848

4949
my $tag_name = $opt_t || "tags";
@@ -68,6 +68,19 @@ END
6868
push (@mergerx, qr/$opt_M/);
6969
}
7070

71+
our %users = ();
72+
if ($opt_A) {
73+
die "Cannot open $opt_A\n" unless -f $opt_A;
74+
open(my $authors,$opt_A);
75+
while(<$authors>) {
76+
chomp;
77+
next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
78+
(my $user,my $name,my $email) = ($1,$2,$3);
79+
$users{$user} = [$name,$email];
80+
}
81+
close($authors);
82+
}
83+
7184
select(STDERR); $|=1; select(STDOUT);
7285

7386

@@ -485,6 +498,10 @@ sub commit {
485498

486499
if (not defined $author) {
487500
$author_name = $author_email = "unknown";
501+
} elsif ($opt_A) {
502+
die "User $author is not listed in $opt_A\n"
503+
unless exists $users{$author};
504+
($author_name,$author_email) = @{$users{$author}};
488505
} elsif ($author =~ /^(.*?)\s+<(.*)>$/) {
489506
($author_name, $author_email) = ($1, $2);
490507
} else {

0 commit comments

Comments
 (0)