* A split_mail_conv() callback that converts an StGit patch to an RFC2822 * message suitable for parsing with git-mailinfo. */
| 794 | * message suitable for parsing with git-mailinfo. |
| 795 | */ |
| 796 | static int stgit_patch_to_mail(FILE *out, FILE *in, int keep_cr UNUSED) |
| 797 | { |
| 798 | struct strbuf sb = STRBUF_INIT; |
| 799 | int subject_printed = 0; |
| 800 | |
| 801 | while (!strbuf_getline_lf(&sb, in)) { |
| 802 | const char *str; |
| 803 | |
| 804 | if (str_isspace(sb.buf)) |
| 805 | continue; |
| 806 | else if (skip_prefix(sb.buf, "Author:", &str)) |
| 807 | fprintf(out, "From:%s\n", str); |
| 808 | else if (starts_with(sb.buf, "From") || starts_with(sb.buf, "Date")) |
| 809 | fprintf(out, "%s\n", sb.buf); |
| 810 | else if (!subject_printed) { |
| 811 | fprintf(out, "Subject: %s\n", sb.buf); |
| 812 | subject_printed = 1; |
| 813 | } else { |
| 814 | fprintf(out, "\n%s\n", sb.buf); |
| 815 | break; |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | strbuf_reset(&sb); |
| 820 | while (strbuf_fread(&sb, 8192, in) > 0) { |
| 821 | fwrite(sb.buf, 1, sb.len, out); |
| 822 | strbuf_reset(&sb); |
| 823 | } |
| 824 | |
| 825 | strbuf_release(&sb); |
| 826 | return 0; |
| 827 | } |
| 828 | |
| 829 | /** |
| 830 | * This function only supports a single StGit series file in `paths`. |
nothing calls this directly
no test coverage detected