* Parses `mail` using git-mailinfo, extracting its patch and authorship info. * state->msg will be set to the patch message. state->author_name, * state->author_email and state->author_date will be set to the patch author's * name, email and date respectively. The patch body will be written to the * state directory's "patch" file. * * Returns 1 if the patch should be skipped, 0 otherwise. *
| 1205 | * Returns 1 if the patch should be skipped, 0 otherwise. |
| 1206 | */ |
| 1207 | static int parse_mail(struct am_state *state, const char *mail) |
| 1208 | { |
| 1209 | FILE *fp; |
| 1210 | struct strbuf sb = STRBUF_INIT; |
| 1211 | struct strbuf msg = STRBUF_INIT; |
| 1212 | struct strbuf author_name = STRBUF_INIT; |
| 1213 | struct strbuf author_date = STRBUF_INIT; |
| 1214 | struct strbuf author_email = STRBUF_INIT; |
| 1215 | int ret = 0; |
| 1216 | struct mailinfo mi; |
| 1217 | |
| 1218 | setup_mailinfo(the_repository, &mi); |
| 1219 | |
| 1220 | if (state->utf8) |
| 1221 | mi.metainfo_charset = get_commit_output_encoding(); |
| 1222 | else |
| 1223 | mi.metainfo_charset = NULL; |
| 1224 | |
| 1225 | switch (state->keep) { |
| 1226 | case KEEP_FALSE: |
| 1227 | break; |
| 1228 | case KEEP_TRUE: |
| 1229 | mi.keep_subject = 1; |
| 1230 | break; |
| 1231 | case KEEP_NON_PATCH: |
| 1232 | mi.keep_non_patch_brackets_in_subject = 1; |
| 1233 | break; |
| 1234 | default: |
| 1235 | BUG("invalid value for state->keep"); |
| 1236 | } |
| 1237 | |
| 1238 | if (state->message_id) |
| 1239 | mi.add_message_id = 1; |
| 1240 | |
| 1241 | switch (state->scissors) { |
| 1242 | case SCISSORS_UNSET: |
| 1243 | break; |
| 1244 | case SCISSORS_FALSE: |
| 1245 | mi.use_scissors = 0; |
| 1246 | break; |
| 1247 | case SCISSORS_TRUE: |
| 1248 | mi.use_scissors = 1; |
| 1249 | break; |
| 1250 | default: |
| 1251 | BUG("invalid value for state->scissors"); |
| 1252 | } |
| 1253 | |
| 1254 | switch (state->quoted_cr) { |
| 1255 | case quoted_cr_unset: |
| 1256 | break; |
| 1257 | case quoted_cr_nowarn: |
| 1258 | case quoted_cr_warn: |
| 1259 | case quoted_cr_strip: |
| 1260 | mi.quoted_cr = state->quoted_cr; |
| 1261 | break; |
| 1262 | default: |
| 1263 | BUG("invalid value for state->quoted_cr"); |
| 1264 | } |
no test coverage detected