From 780c74b21820b84f6ea69a1e4722616f95f89154 Mon Sep 17 00:00:00 2001 From: Karl Lenz Date: Tue, 10 Dec 2019 23:27:53 -0500 Subject: [PATCH] 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 --- git-filter-repo | 2 +- t/t9390-filter-repo.sh | 1 + t/t9390/sample-mailmap | 1 + t/t9390/unusual | 2 +- t/t9390/unusual-filtered | 2 +- t/t9390/unusual-mailmap | 23 +++++++++++++++++++++++ 6 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 t/t9390/unusual-mailmap diff --git a/git-filter-repo b/git-filter-repo index 7c46cf2..b8852ef 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -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)) diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 2173939..2a8e19e 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -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 && diff --git a/t/t9390/sample-mailmap b/t/t9390/sample-mailmap index 4a960f8..cd3485e 100644 --- a/t/t9390/sample-mailmap +++ b/t/t9390/sample-mailmap @@ -4,3 +4,4 @@ Little 'ol Me Little 'ol Me Little O. Me Little 'ol Me Little 'ol Me Little Me +Little John little.john <> diff --git a/t/t9390/unusual b/t/t9390/unusual index dc24ab8..e1babef 100644 --- a/t/t9390/unusual +++ b/t/t9390/unusual @@ -28,7 +28,7 @@ from :2 tag v1.0 from :2 original-oid 0000000000000000000000000000000000000003 -tagger Little John 1535229618 -0700 +tagger little.john <> 1535229618 -0700 data 4 v1.0 diff --git a/t/t9390/unusual-filtered b/t/t9390/unusual-filtered index 6929715..07390bf 100644 --- a/t/t9390/unusual-filtered +++ b/t/t9390/unusual-filtered @@ -17,7 +17,7 @@ from :2 tag v1.0 from :2 -tagger Little John 1535229618 -0700 +tagger little.john <> 1535229618 -0700 data 4 v1.0 done diff --git a/t/t9390/unusual-mailmap b/t/t9390/unusual-mailmap new file mode 100644 index 0000000..6929715 --- /dev/null +++ b/t/t9390/unusual-mailmap @@ -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 1535228562 +0261 +committer Srinivasa Ramanujan 1535228562 +0261 +data 8 +Initial +M 100644 :1 greeting + +reset refs/heads/master +from :2 + +tag v1.0 +from :2 +tagger Little John 1535229618 -0700 +data 4 +v1.0 +done