Skip to content

Commit 41787ff

Browse files
committed
Merge branch 'kl/mailmap-corner-case-and-misc-fixes' into master
Signed-off-by: Elijah Newren <[email protected]>
2 parents 99432eb + caf85b6 commit 41787ff

File tree

7 files changed

+58
-4
lines changed

7 files changed

+58
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/t/test-results
2+
/t/trash directory*

git-filter-repo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class MailmapInfo(object):
267267
self._parse_file(filename)
268268

269269
def _parse_file(self, filename):
270-
name_and_email_re = re.compile(br'(.*?)\s*<([^>]+)>\s*')
270+
name_and_email_re = re.compile(br'(.*?)\s*<([^>]*)>\s*')
271271
comment_re = re.compile(br'\s*#.*')
272272
if not os.access(filename, os.R_OK):
273273
raise SystemExit(_("Cannot read %s") % decode(filename))
@@ -3562,7 +3562,7 @@ class RepoFilter(object):
35623562
self._output = open(self._fe_filt, 'bw')
35633563
else:
35643564
self._output = self._fip.stdin
3565-
if self._args.debug:
3565+
if self._args.debug and not self._args.dry_run:
35663566
self._output = DualFileWriter(self._fip.stdin, self._output)
35673567
tmp = [decode(x) if isinstance(x, bytes) else x for x in fip_cmd]
35683568
print("[DEBUG] Running: {}".format(' '.join(tmp)))

t/t9390-filter-repo.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ filter_testcase degenerate degenerate-keepme --path moduleA/keepme
4848
filter_testcase degenerate degenerate-moduleA --path moduleA
4949
filter_testcase degenerate degenerate-globme --path-glob *me
5050
filter_testcase unusual unusual-filtered --path ''
51+
filter_testcase unusual unusual-mailmap --mailmap ../t9390/sample-mailmap
5152

5253
test_expect_success 'setup path_rename' '
5354
test_create_repo path_rename &&
@@ -443,6 +444,33 @@ test_expect_success '--dry-run' '
443444
)
444445
'
445446

447+
test_expect_success '--dry-run --debug' '
448+
(
449+
git clone file://"$(pwd)"/metasyntactic dry_run_debug &&
450+
cd dry_run_debug &&
451+
452+
git filter-repo --path words --dry-run --debug &&
453+
454+
git show-ref | grep master >out &&
455+
test_line_count = 2 out &&
456+
awk "{print \$1}" out | uniq >out2 &&
457+
test_line_count = 1 out2 &&
458+
459+
test $(git rev-list --count HEAD) = 3 &&
460+
git cat-file --batch-check --batch-all-objects >all-objs &&
461+
test_line_count = 19 all-objs &&
462+
git log --format=%n --name-only | sort | uniq >filenames &&
463+
test_line_count = 9 filenames &&
464+
465+
test_path_is_file .git/filter-repo/fast-export.original &&
466+
grep "^commit " .git/filter-repo/fast-export.original >out &&
467+
test_line_count = 3 out &&
468+
test_path_is_file .git/filter-repo/fast-export.filtered &&
469+
grep "^commit " .git/filter-repo/fast-export.filtered >out &&
470+
test_line_count = 2 out
471+
)
472+
'
473+
446474
test_expect_success '--dry-run --stdin' '
447475
(
448476
git clone file://"$(pwd)"/metasyntactic dry_run_stdin &&

t/t9390/sample-mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Little 'ol Me <[email protected]>
44
Little 'ol Me <[email protected]> Little O. Me
55
66
Little 'ol Me <[email protected]> Little Me <[email protected]>
7+
Little John <[email protected]> little.john <>

t/t9390/unusual

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ from :2
2828
tag v1.0
2929
from :2
3030
original-oid 0000000000000000000000000000000000000003
31-
tagger Little John <[email protected]> 1535229618 -0700
31+
tagger little.john <> 1535229618 -0700
3232
data 4
3333
v1.0
3434

t/t9390/unusual-filtered

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ from :2
1717

1818
tag v1.0
1919
from :2
20-
tagger Little John <[email protected]> 1535229618 -0700
20+
tagger little.john <> 1535229618 -0700
2121
data 4
2222
v1.0
2323
done

t/t9390/unusual-mailmap

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
feature done
2+
blob
3+
mark :1
4+
data 5
5+
hello
6+
reset refs/heads/develop
7+
commit refs/heads/develop
8+
mark :2
9+
author Srinivasa Ramanujan <[email protected]> 1535228562 +0261
10+
committer Srinivasa Ramanujan <[email protected]> 1535228562 +0261
11+
data 8
12+
Initial
13+
M 100644 :1 greeting
14+
15+
reset refs/heads/master
16+
from :2
17+
18+
tag v1.0
19+
from :2
20+
tagger Little John <[email protected]> 1535229618 -0700
21+
data 4
22+
v1.0
23+
done

0 commit comments

Comments
 (0)