MCPcopy Create free account
hub / github.com/git/git / mailinfo

Function mailinfo

mailinfo.c:1195–1237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1193}
1194
1195int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
1196{
1197 FILE *cmitmsg;
1198 int peek;
1199 struct strbuf line = STRBUF_INIT;
1200
1201 cmitmsg = fopen(msg, "w");
1202 if (!cmitmsg) {
1203 perror(msg);
1204 return -1;
1205 }
1206 mi->patchfile = fopen(patch, "w");
1207 if (!mi->patchfile) {
1208 perror(patch);
1209 fclose(cmitmsg);
1210 return -1;
1211 }
1212
1213 mi->p_hdr_data = xcalloc(ARRAY_SIZE(header), sizeof(*(mi->p_hdr_data)));
1214 mi->s_hdr_data = xcalloc(ARRAY_SIZE(header), sizeof(*(mi->s_hdr_data)));
1215
1216 do {
1217 peek = fgetc(mi->input);
1218 if (peek == EOF) {
1219 fclose(cmitmsg);
1220 return error("empty patch: '%s'", patch);
1221 }
1222 } while (isspace(peek));
1223 ungetc(peek, mi->input);
1224
1225 /* process the email header */
1226 while (read_one_header_line(&line, mi->input))
1227 check_header(mi, &line, mi->p_hdr_data, 1);
1228
1229 handle_body(mi, &line);
1230 fwrite(mi->log_message.buf, 1, mi->log_message.len, cmitmsg);
1231 fclose(cmitmsg);
1232 fclose(mi->patchfile);
1233
1234 handle_info(mi);
1235 strbuf_release(&line);
1236 return mi->input_error;
1237}
1238
1239int mailinfo_parse_quoted_cr_action(const char *actionstr, int *action)
1240{

Callers

nothing calls this directly

Calls 7

xcallocFunction · 0.85
errorFunction · 0.85
strbuf_releaseFunction · 0.85
read_one_header_lineFunction · 0.70
check_headerFunction · 0.70
handle_bodyFunction · 0.70
handle_infoFunction · 0.70

Tested by

no test coverage detected