Skip to content

Commit 2d02bc9

Browse files
committed
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 cf6de18 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 <[email protected]>
1 parent 97f4b4c commit 2d02bc9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

t/t4203-mailmap.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,11 @@ test_expect_success 'Blame --porcelain output (complex mapping)' '
746746
EOF
747747
748748
git blame --porcelain one >actual.blame &&
749-
grep -E \
750-
-e "[0-9]+ [0-9]+ [0-9]+$" \
751-
-e "^author .*$" \
752-
actual.blame >actual.grep &&
753-
cut -d " " -f2-4 <actual.grep >actual.fuzz &&
749+
750+
NUM="[0-9][0-9]*" &&
751+
sed -n <actual.blame >actual.fuzz \
752+
-e "s/^author //p" \
753+
-e "s/^$OID_REGEX \\($NUM $NUM $NUM\\)$/\\1/p" &&
754754
test_cmp expect actual.fuzz
755755
'
756756

0 commit comments

Comments
 (0)