]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-svn: allow empty email-address using authors-prog and authors-file
authorAndreas Heiduk <asheiduk@gmail.com>
Sat, 24 Mar 2018 10:20:46 +0000 (11:20 +0100)
committerEric Wong <e@80x24.org>
Thu, 5 Apr 2018 19:22:06 +0000 (19:22 +0000)
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>
Documentation/git-svn.txt
perl/Git/SVN.pm
t/t9130-git-svn-authors-file.sh
t/t9138-git-svn-authors-prog.sh

index b858374649b641bbdbb876b9614ee0add88c7db2..d59379ee2344690926f5e0bee282c81445d3061d 100644 (file)
@@ -635,7 +635,8 @@ config key: svn.findcopiesharder
 
 -A<filename>::
 --authors-file=<filename>::
-       Syntax is compatible with the file used by 'git cvsimport':
+       Syntax is compatible with the file used by 'git cvsimport' but
+       an empty email address can be supplied with '<>':
 +
 ------------------------------------------------------------------------
        loginname = Joe User <user@example.com>
@@ -654,8 +655,9 @@ config key: svn.authorsfile
        If this option is specified, for each SVN committer name that
        does not exist in the authors file, the given file is executed
        with the committer name as the first argument.  The program is
-       expected to return a single line of the form "Name <email>",
-       which will be treated as if included in the authors file.
+       expected to return a single line of the form "Name <email>" or
+       "Name <>", which will be treated as if included in the authors
+       file.
 +
 Due to historical reasons a relative 'filename' is first searched
 relative to the current directory for 'init' and 'clone' and relative
index 991a5885e9230b1f55bd6f3b7f7b53321bf9e562..76b29659057d329670ce07b102de37caf133e97f 100644 (file)
@@ -1482,7 +1482,6 @@ sub call_authors_prog {
        }
        if ($author =~ /^\s*(.+?)\s*<(.*)>\s*$/) {
                my ($name, $email) = ($1, $2);
-               $email = undef if length $2 == 0;
                return [$name, $email];
        } else {
                die "Author: $orig_author: $::_authors_prog returned "
@@ -2020,8 +2019,8 @@ sub make_log_entry {
                remove_username($full_url);
                $log_entry{metadata} = "$full_url\@$r $uuid";
                $log_entry{svm_revision} = $r;
-               $email ||= "$author\@$uuid";
-               $commit_email ||= "$author\@$uuid";
+               $email = "$author\@$uuid" unless defined $email;
+               $commit_email = "$author\@$uuid" unless defined $commit_email;
        } elsif ($self->use_svnsync_props) {
                my $full_url = canonicalize_url(
                        add_path_to_url( $self->svnsync->{url}, $self->path )
@@ -2029,15 +2028,15 @@ sub make_log_entry {
                remove_username($full_url);
                my $uuid = $self->svnsync->{uuid};
                $log_entry{metadata} = "$full_url\@$rev $uuid";
-               $email ||= "$author\@$uuid";
-               $commit_email ||= "$author\@$uuid";
+               $email = "$author\@$uuid" unless defined $email;
+               $commit_email = "$author\@$uuid" unless defined $commit_email;
        } else {
                my $url = $self->metadata_url;
                remove_username($url);
                my $uuid = $self->rewrite_uuid || $self->ra->get_uuid;
                $log_entry{metadata} = "$url\@$rev " . $uuid;
-               $email ||= "$author\@" . $uuid;
-               $commit_email ||= "$author\@" . $uuid;
+               $email = "$author\@$uuid" unless defined $email;
+               $commit_email = "$author\@$uuid" unless defined $commit_email;
        }
        $log_entry{name} = $name;
        $log_entry{email} = $email;
index 41264818ccdd85abb4b0a17c8a508d4bcbfe57f5..6af6daf461493c1ac9cd0a60982cdc52209ab45b 100755 (executable)
@@ -108,6 +108,20 @@ test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
        )
 '
 
+cat >> svn-authors <<EOF
+ff = FFFFFFF FFFFFFF <>
+EOF
+
+test_expect_success 'authors-file imported user without email' '
+       svn_cmd mkdir -m aa/branches/ff --username ff "$svnrepo/aa/branches/ff" &&
+       (
+               cd aa-work &&
+               git svn fetch --authors-file=../svn-authors &&
+               git rev-list -1 --pretty=raw refs/remotes/origin/ff | \
+                 grep "^author FFFFFFF FFFFFFF <> "
+       )
+       '
+
 test_debug 'GIT_DIR=gitconfig.clone/.git git log'
 
 test_done
index 7d7e9d46bc6bf40f52efffede6b369f052c46843..e94d2a684a7a75c988b967aeef356df6fda42fb1 100755 (executable)
@@ -9,7 +9,9 @@ test_description='git svn authors prog tests'
 
 write_script svn-authors-prog "$PERL_PATH" <<-\EOF
        $_ = shift;
-       if (s/-sub$//)  {
+       if (s/-hermit//) {
+               print "$_ <>\n";
+       } elsif (s/-sub$//)  {
                print "$_ <$_\@sub.example.com>\n";
        } else {
                print "$_ <$_\@example.com>\n";
@@ -68,6 +70,28 @@ test_expect_success 'authors-file overrode authors-prog' '
 git --git-dir=x/.git config --unset svn.authorsfile
 git --git-dir=x/.git config --unset svn.authorsprog
 
+test_expect_success 'authors-prog imported user without email' '
+       svn mkdir -m gg --username gg-hermit "$svnrepo"/gg &&
+       (
+               cd x &&
+               git svn fetch --authors-prog=../svn-authors-prog &&
+               git rev-list -1 --pretty=raw refs/remotes/git-svn | \
+                 grep "^author gg <> "
+       )
+'
+
+test_expect_success 'imported without authors-prog and authors-file' '
+       svn mkdir -m hh --username hh "$svnrepo"/hh &&
+       (
+               uuid=$(svn info "$svnrepo" |
+                       sed -n "s/^Repository UUID: //p") &&
+               cd x &&
+               git svn fetch &&
+               git rev-list -1 --pretty=raw refs/remotes/git-svn | \
+                 grep "^author hh <hh@$uuid> "
+       )
+'
+
 test_expect_success 'authors-prog handled special characters in username' '
        svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
        (