mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-06 18:32:14 +02:00
filter-repo: only set author from committer if author email not set
Some commits may have a valid author email, but no valid author name. Old versions of git didn't enforce a non-empty name. Setting the author data from the committer is wrong in this case. Also add a test case for this to t9390. Example: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6295cdf656de63d6d1123def71daba6cd91939c (en: replaced with a dedicated test instead of tweaking existing ones) Signed-off-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
7b3e714b94
commit
282f8ddb9b
@ -1189,13 +1189,14 @@ class FastExportParser(object):
|
|||||||
original_id = self._parse_original_id();
|
original_id = self._parse_original_id();
|
||||||
|
|
||||||
author_name = None
|
author_name = None
|
||||||
|
author_email = None
|
||||||
if self._currentline.startswith(b'author'):
|
if self._currentline.startswith(b'author'):
|
||||||
(author_name, author_email, author_date) = self._parse_user(b'author')
|
(author_name, author_email, author_date) = self._parse_user(b'author')
|
||||||
|
|
||||||
(committer_name, committer_email, committer_date) = \
|
(committer_name, committer_email, committer_date) = \
|
||||||
self._parse_user(b'committer')
|
self._parse_user(b'committer')
|
||||||
|
|
||||||
if not author_name:
|
if not author_name and not author_email:
|
||||||
(author_name, author_email, author_date) = \
|
(author_name, author_email, author_date) = \
|
||||||
(committer_name, committer_email, committer_date)
|
(committer_name, committer_email, committer_date)
|
||||||
|
|
||||||
|
@ -1649,4 +1649,37 @@ test_expect_success '--version' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty author ident' '
|
||||||
|
test_create_repo empty_author_ident &&
|
||||||
|
(
|
||||||
|
cd empty_author_ident &&
|
||||||
|
|
||||||
|
git init &&
|
||||||
|
cat <<-EOF | git fast-import --quiet &&
|
||||||
|
feature done
|
||||||
|
blob
|
||||||
|
mark :1
|
||||||
|
data 8
|
||||||
|
initial
|
||||||
|
|
||||||
|
reset refs/heads/develop
|
||||||
|
commit refs/heads/develop
|
||||||
|
mark :2
|
||||||
|
author <empty@ident.ity> 1535228562 -0700
|
||||||
|
committer Full Name <email@add.ress> 1535228562 -0700
|
||||||
|
data 8
|
||||||
|
Initial
|
||||||
|
M 100644 :1 filename
|
||||||
|
|
||||||
|
done
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git filter-repo --force --path-rename filename:stuff &&
|
||||||
|
|
||||||
|
git log --format=%an develop >actual &&
|
||||||
|
echo >expect &&
|
||||||
|
test_cmp expect actual
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user