filter-repo: parse mailmap entries with no email address

The mailmap format parsed by the "git shortlog" command allows for
matching mailmap entries with no email address. This is admittedly an
edge case, because most Git commits will have an email address
associated with them as well as a name, but technically the address
isn't required, and "git shortlog" accommodates that in its mailmap
format. This commit teaches git-filter-repo to do the same thing.

Signed-off-by: Karl Lenz <xorangekiller@gmail.com>
pull/43/head
Karl Lenz 5 years ago
parent 5c960b5a64
commit 780c74b218

@ -267,7 +267,7 @@ class MailmapInfo(object):
self._parse_file(filename)
def _parse_file(self, filename):
name_and_email_re = re.compile(br'(.*?)\s*<([^>]+)>\s*')
name_and_email_re = re.compile(br'(.*?)\s*<([^>]*)>\s*')
comment_re = re.compile(br'\s*#.*')
if not os.access(filename, os.R_OK):
raise SystemExit(_("Cannot read %s") % decode(filename))

@ -48,6 +48,7 @@ filter_testcase degenerate degenerate-keepme --path moduleA/keepme
filter_testcase degenerate degenerate-moduleA --path moduleA
filter_testcase degenerate degenerate-globme --path-glob *me
filter_testcase unusual unusual-filtered --path ''
filter_testcase unusual unusual-mailmap --mailmap ../t9390/sample-mailmap
test_expect_success 'setup path_rename' '
test_create_repo path_rename &&

@ -4,3 +4,4 @@ Little 'ol Me <me@little.net>
Little 'ol Me <me@little.net> Little O. Me
Little 'ol Me <me@little.net> <me@fire.com>
Little 'ol Me <me@little.net> Little Me <me@bigcompany.com>
Little John <second@merry.men> little.john <>

@ -28,7 +28,7 @@ from :2
tag v1.0
from :2
original-oid 0000000000000000000000000000000000000003
tagger Little John <second@merry.men> 1535229618 -0700
tagger little.john <> 1535229618 -0700
data 4
v1.0

@ -17,7 +17,7 @@ from :2
tag v1.0
from :2
tagger Little John <second@merry.men> 1535229618 -0700
tagger little.john <> 1535229618 -0700
data 4
v1.0
done

@ -0,0 +1,23 @@
feature done
blob
mark :1
data 5
hello
reset refs/heads/develop
commit refs/heads/develop
mark :2
author Srinivasa Ramanujan <fellow@cambridge.org> 1535228562 +0261
committer Srinivasa Ramanujan <fellow@cambridge.org> 1535228562 +0261
data 8
Initial
M 100644 :1 greeting
reset refs/heads/master
from :2
tag v1.0
from :2
tagger Little John <second@merry.men> 1535229618 -0700
data 4
v1.0
done
Loading…
Cancel
Save