static int handle_commit_msg(char *line, unsigned linesize) { static int still_looking = 1; char *endline = line + linesize; if (!cmitmsg) return 0; if (still_looking) { char *cp = line; if (isspace(*line)) { for (cp = line + 1; *cp; cp++) { if (!isspace(*cp)) break; } if (!*cp) return 0; } if ((still_looking = check_header(cp, endline - cp, s_hdr_data, 0)) != 0) return 0; } /* normalize the log message to UTF-8. */ if (metainfo_charset) convert_to_utf8(line, endline - line, charset); if (patchbreak(line)) { fclose(cmitmsg); cmitmsg = NULL; return 1; } fputs(line, cmitmsg); return 0; }
static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line) { assert(!mi->filter_stage); if (mi->header_stage) { if (!line->len || (line->len == 1 && line->buf[0] == '\n')) { if (mi->inbody_header_accum.len) { flush_inbody_header_accum(mi); mi->header_stage = 0; } return 0; } } if (mi->use_inbody_headers && mi->header_stage) { mi->header_stage = check_inbody_header(mi, line); if (mi->header_stage) return 0; } else /* Only trim the first (blank) line of the commit message * when ignoring in-body headers. */ mi->header_stage = 0; /* normalize the log message to UTF-8. */ if (convert_to_utf8(mi, line, mi->charset.buf)) return 0; /* mi->input_error already set */ if (mi->use_scissors && is_scissors_line(line->buf)) { int i; strbuf_setlen(&mi->log_message, 0); mi->header_stage = 1; /* * We may have already read "secondary headers"; purge * them to give ourselves a clean restart. */ for (i = 0; header[i]; i++) { if (mi->s_hdr_data[i]) strbuf_release(mi->s_hdr_data[i]); mi->s_hdr_data[i] = NULL; } return 0; } if (patchbreak(line)) { if (mi->message_id) strbuf_addf(&mi->log_message, "Message-Id: %s\n", mi->message_id); return 1; } strbuf_addbuf(&mi->log_message, line); return 0; }
static int handle_commit_msg(struct strbuf *line) { static int still_looking = 1; if (!cmitmsg) return 0; if (still_looking) { strbuf_ltrim(line); if (!line->len) return 0; still_looking = check_header(line, s_hdr_data, 0); if (still_looking) return 0; } /* normalize the log message to UTF-8. */ if (metainfo_charset) convert_to_utf8(line, charset.buf); if (use_scissors && is_scissors_line(line)) { int i; rewind(cmitmsg); ftruncate(fileno(cmitmsg), 0); still_looking = 1; /* * We may have already read "secondary headers"; purge * them to give ourselves a clean restart. */ for (i = 0; header[i]; i++) { if (s_hdr_data[i]) strbuf_release(s_hdr_data[i]); s_hdr_data[i] = NULL; } return 0; } if (patchbreak(line)) { fclose(cmitmsg); cmitmsg = NULL; return 1; } fputs(line->buf, cmitmsg); return 0; }