Skip to content

Commit fe0a9ea

Browse files
committed
Merge branch 'svn/authors-prog-2' of git://bogomips.org/git-svn
* 'svn/authors-prog-2' of git://bogomips.org/git-svn: git-svn: allow empty email-address using authors-prog and authors-file git-svn: search --authors-prog in PATH too
2 parents 8b026ed + cb427e9 commit fe0a9ea

File tree

5 files changed

+57
-12
lines changed

5 files changed

+57
-12
lines changed

Documentation/git-svn.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,8 @@ config key: svn.findcopiesharder
635635

636636
-A<filename>::
637637
--authors-file=<filename>::
638-
Syntax is compatible with the file used by 'git cvsimport':
638+
Syntax is compatible with the file used by 'git cvsimport' but
639+
an empty email address can be supplied with '<>':
639640
+
640641
------------------------------------------------------------------------
641642
loginname = Joe User <[email protected]>
@@ -654,8 +655,14 @@ config key: svn.authorsfile
654655
If this option is specified, for each SVN committer name that
655656
does not exist in the authors file, the given file is executed
656657
with the committer name as the first argument. The program is
657-
expected to return a single line of the form "Name <email>",
658-
which will be treated as if included in the authors file.
658+
expected to return a single line of the form "Name <email>" or
659+
"Name <>", which will be treated as if included in the authors
660+
file.
661+
+
662+
Due to historical reasons a relative 'filename' is first searched
663+
relative to the current directory for 'init' and 'clone' and relative
664+
to the root of the working tree for 'fetch'. If 'filename' is
665+
not found, it is searched like any other command in '$PATH'.
659666
+
660667
[verse]
661668
config key: svn.authorsProg

git-svn.perl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ sub term_init {
374374
usage(1) unless defined $cmd;
375375
load_authors() if $_authors;
376376
if (defined $_authors_prog) {
377-
$_authors_prog = "'" . File::Spec->rel2abs($_authors_prog) . "'";
377+
my $abs_file = File::Spec->rel2abs($_authors_prog);
378+
$_authors_prog = "'" . $abs_file . "'" if -x $abs_file;
378379
}
379380

380381
unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) {

perl/Git/SVN.pm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,6 @@ sub call_authors_prog {
14821482
}
14831483
if ($author =~ /^\s*(.+?)\s*<(.*)>\s*$/) {
14841484
my ($name, $email) = ($1, $2);
1485-
$email = undef if length $2 == 0;
14861485
return [$name, $email];
14871486
} else {
14881487
die "Author: $orig_author: $::_authors_prog returned "
@@ -2020,24 +2019,24 @@ sub make_log_entry {
20202019
remove_username($full_url);
20212020
$log_entry{metadata} = "$full_url\@$r $uuid";
20222021
$log_entry{svm_revision} = $r;
2023-
$email ||= "$author\@$uuid";
2024-
$commit_email ||= "$author\@$uuid";
2022+
$email = "$author\@$uuid" unless defined $email;
2023+
$commit_email = "$author\@$uuid" unless defined $commit_email;
20252024
} elsif ($self->use_svnsync_props) {
20262025
my $full_url = canonicalize_url(
20272026
add_path_to_url( $self->svnsync->{url}, $self->path )
20282027
);
20292028
remove_username($full_url);
20302029
my $uuid = $self->svnsync->{uuid};
20312030
$log_entry{metadata} = "$full_url\@$rev $uuid";
2032-
$email ||= "$author\@$uuid";
2033-
$commit_email ||= "$author\@$uuid";
2031+
$email = "$author\@$uuid" unless defined $email;
2032+
$commit_email = "$author\@$uuid" unless defined $commit_email;
20342033
} else {
20352034
my $url = $self->metadata_url;
20362035
remove_username($url);
20372036
my $uuid = $self->rewrite_uuid || $self->ra->get_uuid;
20382037
$log_entry{metadata} = "$url\@$rev " . $uuid;
2039-
$email ||= "$author\@" . $uuid;
2040-
$commit_email ||= "$author\@" . $uuid;
2038+
$email = "$author\@$uuid" unless defined $email;
2039+
$commit_email = "$author\@$uuid" unless defined $commit_email;
20412040
}
20422041
$log_entry{name} = $name;
20432042
$log_entry{email} = $email;

t/t9130-git-svn-authors-file.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
112112
)
113113
'
114114

115+
cat >> svn-authors <<EOF
116+
ff = FFFFFFF FFFFFFF <>
117+
EOF
118+
119+
test_expect_success 'authors-file imported user without email' '
120+
svn_cmd mkdir -m aa/branches/ff --username ff "$svnrepo/aa/branches/ff" &&
121+
(
122+
cd aa-work &&
123+
git svn fetch --authors-file=../svn-authors &&
124+
git rev-list -1 --pretty=raw refs/remotes/origin/ff | \
125+
grep "^author FFFFFFF FFFFFFF <> "
126+
)
127+
'
128+
115129
test_debug 'GIT_DIR=gitconfig.clone/.git git log'
116130

117131
test_done

t/t9138-git-svn-authors-prog.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ test_description='git svn authors prog tests'
99

1010
write_script svn-authors-prog "$PERL_PATH" <<-\EOF
1111
$_ = shift;
12-
if (s/-sub$//) {
12+
if (s/-hermit//) {
13+
print "$_ <>\n";
14+
} elsif (s/-sub$//) {
1315
print "$_ <$_\@sub.example.com>\n";
1416
} else {
1517
print "$_ <$_\@example.com>\n";
@@ -69,6 +71,28 @@ test_expect_success 'authors-file overrode authors-prog' '
6971
git --git-dir=x/.git config --unset svn.authorsfile
7072
git --git-dir=x/.git config --unset svn.authorsprog
7173

74+
test_expect_success 'authors-prog imported user without email' '
75+
svn mkdir -m gg --username gg-hermit "$svnrepo"/gg &&
76+
(
77+
cd x &&
78+
git svn fetch --authors-prog=../svn-authors-prog &&
79+
git rev-list -1 --pretty=raw refs/remotes/git-svn | \
80+
grep "^author gg <> "
81+
)
82+
'
83+
84+
test_expect_success 'imported without authors-prog and authors-file' '
85+
svn mkdir -m hh --username hh "$svnrepo"/hh &&
86+
(
87+
uuid=$(svn info "$svnrepo" |
88+
sed -n "s/^Repository UUID: //p") &&
89+
cd x &&
90+
git svn fetch &&
91+
git rev-list -1 --pretty=raw refs/remotes/git-svn | \
92+
grep "^author hh <hh@$uuid> "
93+
)
94+
'
95+
7296
test_expect_success 'authors-prog handled special characters in username' '
7397
svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
7498
(

0 commit comments

Comments
 (0)