| 390 | } |
| 391 | |
| 392 | void apply_mailmap_to_header(struct strbuf *buf, const char **header, |
| 393 | struct string_list *mailmap) |
| 394 | { |
| 395 | size_t buf_offset = 0; |
| 396 | |
| 397 | if (!mailmap) |
| 398 | return; |
| 399 | |
| 400 | for (;;) { |
| 401 | const char *person, *line; |
| 402 | size_t i; |
| 403 | int found_header = 0; |
| 404 | |
| 405 | line = buf->buf + buf_offset; |
| 406 | if (!*line || *line == '\n') |
| 407 | return; /* End of headers */ |
| 408 | |
| 409 | for (i = 0; header[i]; i++) |
| 410 | if (skip_prefix(line, header[i], &person)) { |
| 411 | const char *endp = strchrnul(person, '\n'); |
| 412 | found_header = 1; |
| 413 | buf_offset += endp - line; |
| 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++; |
| 419 | break; |
| 420 | } |
| 421 | |
| 422 | if (!found_header) { |
| 423 | buf_offset = strchrnul(line, '\n') - buf->buf; |
| 424 | if (buf->buf[buf_offset] == '\n') |
| 425 | buf_offset++; |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | static void ident_env_hint(enum want_ident whose_ident) |
| 431 | { |
no test coverage detected