Skip to content

Commit cb427e9

Browse files
asheidukEric Wong
authored and
Eric Wong
committed
git-svn: allow empty email-address using authors-prog and authors-file
The email address in --authors-file and --authors-prog can be empty but git-svn translated it into a fictional email address in the form jondoe <jondoe@6aafaa21e0fb4338a68ab372a049893d> containing the SVN repository UUID. Now git-svn behaves like git-commit: If the email is *explicitly* set to the empty string using '<>', the commit does not contain an email address, only the name: jondoe <> Allowing to remove the email address *intentionally* prevents automatic systems from sending emails to those fictional addresses and avoids cluttering the log output with unnecessary stuff. Signed-off-by: Andreas Heiduk <[email protected]> Signed-off-by: Eric Wong <[email protected]>
1 parent 9c18398 commit cb427e9

File tree

4 files changed

+50
-11
lines changed

4 files changed

+50
-11
lines changed

Documentation/git-svn.txt

Lines changed: 5 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,9 @@ 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.
659661
+
660662
Due to historical reasons a relative 'filename' is first searched
661663
relative to the current directory for 'init' and 'clone' and relative

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
@@ -108,6 +108,20 @@ test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
108108
)
109109
'
110110

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

113127
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";
@@ -68,6 +70,28 @@ test_expect_success 'authors-file overrode authors-prog' '
6870
git --git-dir=x/.git config --unset svn.authorsfile
6971
git --git-dir=x/.git config --unset svn.authorsprog
7072

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

0 commit comments

Comments
 (0)