Skip to content

Commit

Permalink
Merge branch 'svn/authors-prog-2' of git://bogomips.org/git-svn
Browse files Browse the repository at this point in the history
* '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
  • Loading branch information
gitster committed Apr 11, 2018
2 parents 8b026ed + cb427e9 commit fe0a9ea
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 12 deletions.
13 changes: 10 additions & 3 deletions Documentation/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand All @@ -654,8 +655,14 @@ 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
to the root of the working tree for 'fetch'. If 'filename' is
not found, it is searched like any other command in '$PATH'.
+
[verse]
config key: svn.authorsProg
Expand Down
3 changes: 2 additions & 1 deletion git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ sub term_init {
usage(1) unless defined $cmd;
load_authors() if $_authors;
if (defined $_authors_prog) {
$_authors_prog = "'" . File::Spec->rel2abs($_authors_prog) . "'";
my $abs_file = File::Spec->rel2abs($_authors_prog);
$_authors_prog = "'" . $abs_file . "'" if -x $abs_file;
}

unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) {
Expand Down
13 changes: 6 additions & 7 deletions perl/Git/SVN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -2020,24 +2019,24 @@ 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 )
);
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;
Expand Down
14 changes: 14 additions & 0 deletions t/t9130-git-svn-authors-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,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
26 changes: 25 additions & 1 deletion t/t9138-git-svn-authors-prog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -69,6 +71,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 &&
(
Expand Down

0 comments on commit fe0a9ea

Please sign in to comment.