Merge branch 'sa/multi-mailmap-fix'
When asking to apply mailmap to both author and committer field while showing a commit object, the field that appears later was not correctly parsed and replaced, which has been corrected. * sa/multi-mailmap-fix: cat-file: fix mailmap application for different author and committermaint
commit
1e60e1d6d8
4
ident.c
4
ident.c
|
@ -412,6 +412,10 @@ void apply_mailmap_to_header(struct strbuf *buf, const char **header,
|
|||
found_header = 1;
|
||||
buf_offset += endp - line;
|
||||
buf_offset += rewrite_ident_line(person, endp - person, buf, mailmap);
|
||||
/* Recompute endp after potential buffer reallocation */
|
||||
endp = buf->buf + buf_offset;
|
||||
if (*endp == '\n')
|
||||
buf_offset++;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1133,4 +1133,37 @@ test_expect_success 'git cat-file --batch-command returns correct size with --us
|
|||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'git cat-file --mailmap works with different author and committer' '
|
||||
test_when_finished "rm .mailmap" &&
|
||||
cat >.mailmap <<-\EOF &&
|
||||
Mailmapped User <mailmapped-user@gitlab.com> C O Mitter <committer@example.com>
|
||||
EOF
|
||||
git commit --allow-empty -m "different author/committer" \
|
||||
--author="Different Author <different@example.com>" &&
|
||||
cat >expect <<-\EOF &&
|
||||
author Different Author <different@example.com>
|
||||
committer Mailmapped User <mailmapped-user@gitlab.com>
|
||||
EOF
|
||||
git cat-file --mailmap commit HEAD >log &&
|
||||
sed -n -e "/^author /s/>.*/>/p" -e "/^committer /s/>.*/>/p" log >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'git cat-file --mailmap maps both author and committer when both need mapping' '
|
||||
test_when_finished "rm .mailmap" &&
|
||||
cat >.mailmap <<-\EOF &&
|
||||
Mapped Author <mapped-author@example.com> <different@example.com>
|
||||
Mapped Committer <mapped-committer@example.com> C O Mitter <committer@example.com>
|
||||
EOF
|
||||
git commit --allow-empty -m "both author and committer mapped" \
|
||||
--author="Different Author <different@example.com>" &&
|
||||
cat >expect <<-\EOF &&
|
||||
author Mapped Author <mapped-author@example.com>
|
||||
committer Mapped Committer <mapped-committer@example.com>
|
||||
EOF
|
||||
git cat-file --mailmap commit HEAD >log &&
|
||||
sed -n -e "/^author /s/>.*/>/p" -e "/^committer /s/>.*/>/p" log >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in New Issue