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 <asheiduk@gmail.com> Signed-off-by: Eric Wong <e@80x24.org>
Andreas Heiduk committed
Mar 24, 2018 at 11:20 UTC
cb427e9eb0243fe7a1a22ea3bd0a46b7410c0bf3
4 files changed
+50
-11
Documentation/git-svn.txt
+5
-3
@@ -635,7 +635,8 @@ config key: svn.findcopiesharder
635
636
-A<filename>::
637
--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 '<>':
640
+
641
------------------------------------------------------------------------
642
loginname = Joe User <user@example.com>
@@ -654,8 +655,9 @@ config key: svn.authorsfile
655
If this option is specified, for each SVN committer name that
656
does not exist in the authors file, the given file is executed
657
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
perl/Git/SVN.pm
+6
-7
@@ -1482,7 +1482,6 @@ sub call_authors_prog {
1482
}
1483
if ($author =~ /^\s*(.+?)\s*<(.*)>\s*$/) {
1484
my ($name, $email) = ($1, $2);
1485
- $email = undef if length $2 == 0;
1485
return [$name, $email];
1486
} else {
1487
die "Author: $orig_author: $::_authors_prog returned "
@@ -2020,8 +2019,8 @@ sub make_log_entry {
2019
remove_username($full_url);
2020
$log_entry{metadata} = "$full_url\@$r $uuid";
2021
$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;
2024
} elsif ($self->use_svnsync_props) {
2025
my $full_url = canonicalize_url(
2026
add_path_to_url( $self->svnsync->{url}, $self->path )
@@ -2029,15 +2028,15 @@ sub make_log_entry {
2028
remove_username($full_url);
2029
my $uuid = $self->svnsync->{uuid};
2030
$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;
2033
} else {
2034
my $url = $self->metadata_url;
2035
remove_username($url);
2036
my $uuid = $self->rewrite_uuid || $self->ra->get_uuid;
2037
$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;
2040
}
2041
$log_entry{name} = $name;
2042
$log_entry{email} = $email;
t/t9130-git-svn-authors-file.sh
+14
@@ -108,6 +108,20 @@ test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
108
)
109
'
110
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
+
125
test_debug 'GIT_DIR=gitconfig.clone/.git git log'
126
127
test_done
t/t9138-git-svn-authors-prog.sh
+25
-1
@@ -9,7 +9,9 @@ test_description='git svn authors prog tests'
9
10
write_script svn-authors-prog "$PERL_PATH" <<-\EOF
11
$_ = shift;
12
- if (s/-sub$//) {
12
+ if (s/-hermit//) {
13
+ print "$_ <>\n";
14
+ } elsif (s/-sub$//) {
15
print "$_ <$_\@sub.example.com>\n";
16
} else {
17
print "$_ <$_\@example.com>\n";
@@ -68,6 +70,28 @@ test_expect_success 'authors-file overrode authors-prog' '
70
git --git-dir=x/.git config --unset svn.authorsfile
71
git --git-dir=x/.git config --unset svn.authorsprog
72
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
+
95
test_expect_success 'authors-prog handled special characters in username' '
96
svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
97
(