Merge branch 'kl/mailmap-corner-case-and-misc-fixes' into master

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2019-12-26 16:23:15 -08:00
commit 41787ff365
7 changed files with 58 additions and 4 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/t/test-results
/t/trash directory*

View File

@ -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))
@ -3562,7 +3562,7 @@ class RepoFilter(object):
self._output = open(self._fe_filt, 'bw')
else:
self._output = self._fip.stdin
if self._args.debug:
if self._args.debug and not self._args.dry_run:
self._output = DualFileWriter(self._fip.stdin, self._output)
tmp = [decode(x) if isinstance(x, bytes) else x for x in fip_cmd]
print("[DEBUG] Running: {}".format(' '.join(tmp)))

View File

@ -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 &&
@ -443,6 +444,33 @@ test_expect_success '--dry-run' '
)
'
test_expect_success '--dry-run --debug' '
(
git clone file://"$(pwd)"/metasyntactic dry_run_debug &&
cd dry_run_debug &&
git filter-repo --path words --dry-run --debug &&
git show-ref | grep master >out &&
test_line_count = 2 out &&
awk "{print \$1}" out | uniq >out2 &&
test_line_count = 1 out2 &&
test $(git rev-list --count HEAD) = 3 &&
git cat-file --batch-check --batch-all-objects >all-objs &&
test_line_count = 19 all-objs &&
git log --format=%n --name-only | sort | uniq >filenames &&
test_line_count = 9 filenames &&
test_path_is_file .git/filter-repo/fast-export.original &&
grep "^commit " .git/filter-repo/fast-export.original >out &&
test_line_count = 3 out &&
test_path_is_file .git/filter-repo/fast-export.filtered &&
grep "^commit " .git/filter-repo/fast-export.filtered >out &&
test_line_count = 2 out
)
'
test_expect_success '--dry-run --stdin' '
(
git clone file://"$(pwd)"/metasyntactic dry_run_stdin &&

View File

@ -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 <>

View File

@ -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

View File

@ -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

23
t/t9390/unusual-mailmap Normal file
View File

@ -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