Git fork

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 committer

+37
+4
ident.c
··· 412 412 found_header = 1; 413 413 buf_offset += endp - line; 414 414 buf_offset += rewrite_ident_line(person, endp - person, buf, mailmap); 415 + /* Recompute endp after potential buffer reallocation */ 416 + endp = buf->buf + buf_offset; 417 + if (*endp == '\n') 418 + buf_offset++; 415 419 break; 416 420 } 417 421
+33
t/t4203-mailmap.sh
··· 1133 1133 test_cmp expect actual 1134 1134 ' 1135 1135 1136 + test_expect_success 'git cat-file --mailmap works with different author and committer' ' 1137 + test_when_finished "rm .mailmap" && 1138 + cat >.mailmap <<-\EOF && 1139 + Mailmapped User <mailmapped-user@gitlab.com> C O Mitter <committer@example.com> 1140 + EOF 1141 + git commit --allow-empty -m "different author/committer" \ 1142 + --author="Different Author <different@example.com>" && 1143 + cat >expect <<-\EOF && 1144 + author Different Author <different@example.com> 1145 + committer Mailmapped User <mailmapped-user@gitlab.com> 1146 + EOF 1147 + git cat-file --mailmap commit HEAD >log && 1148 + sed -n -e "/^author /s/>.*/>/p" -e "/^committer /s/>.*/>/p" log >actual && 1149 + test_cmp expect actual 1150 + ' 1151 + 1152 + test_expect_success 'git cat-file --mailmap maps both author and committer when both need mapping' ' 1153 + test_when_finished "rm .mailmap" && 1154 + cat >.mailmap <<-\EOF && 1155 + Mapped Author <mapped-author@example.com> <different@example.com> 1156 + Mapped Committer <mapped-committer@example.com> C O Mitter <committer@example.com> 1157 + EOF 1158 + git commit --allow-empty -m "both author and committer mapped" \ 1159 + --author="Different Author <different@example.com>" && 1160 + cat >expect <<-\EOF && 1161 + author Mapped Author <mapped-author@example.com> 1162 + committer Mapped Committer <mapped-committer@example.com> 1163 + EOF 1164 + git cat-file --mailmap commit HEAD >log && 1165 + sed -n -e "/^author /s/>.*/>/p" -e "/^committer /s/>.*/>/p" log >actual && 1166 + test_cmp expect actual 1167 + ' 1168 + 1136 1169 test_done