diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-01-14 23:21:55 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-01-15 08:54:52 +0300 |
commit | 2d02bc91c0aa1ced659a21ce75befcd033a4f923 (patch) | |
tree | 2ba8a3e5358485a39896fabb926de482fc71b8e8 /t/t4203-mailmap.sh | |
parent | 97f4b4c4e79f7726acca50971b4cf851a3219347 (diff) |
t4203: make blame output massaging more robust
In the "git blame --porcelain" output, lines that ends with three
integers may not be the line that shows a commit object with line
numbers and block length (the contents from the blamed file or the
summary field can have a line that happens to match). Also, the
names of the author may have more than three SP separated tokens
("git blame -L242,+1 cf6de18aabf7 Documentation/SubmittingPatches"
gives an example). The existing "grep -E | cut" pipeline is a bit
too loose on these two points.
While they can be assumed on the test data, it is not so hard to
use the right pattern from the documented format, so let's do so.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4203-mailmap.sh')
-rwxr-xr-x | t/t4203-mailmap.sh | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index c9cb1aa127..a3da473689 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -746,11 +746,11 @@ test_expect_success 'Blame --porcelain output (complex mapping)' ' EOF git blame --porcelain one >actual.blame && - grep -E \ - -e "[0-9]+ [0-9]+ [0-9]+$" \ - -e "^author .*$" \ - actual.blame >actual.grep && - cut -d " " -f2-4 <actual.grep >actual.fuzz && + + NUM="[0-9][0-9]*" && + sed -n <actual.blame >actual.fuzz \ + -e "s/^author //p" \ + -e "s/^$OID_REGEX \\($NUM $NUM $NUM\\)$/\\1/p" && test_cmp expect actual.fuzz ' |