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

Function handle_commit_msg

mailinfo.c:793–848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
794{
795 assert(!mi->filter_stage);
796
797 if (mi->header_stage) {
798 if (!line->len || (line->len == 1 && line->buf[0] == '\n')) {
799 if (mi->inbody_header_accum.len) {
800 flush_inbody_header_accum(mi);
801 mi->header_stage = 0;
802 }
803 return 0;
804 }
805 }
806
807 if (mi->use_inbody_headers && mi->header_stage) {
808 mi->header_stage = check_inbody_header(mi, line);
809 if (mi->header_stage)
810 return 0;
811 } else
812 /* Only trim the first (blank) line of the commit message
813 * when ignoring in-body headers.
814 */
815 mi->header_stage = 0;
816
817 /* normalize the log message to UTF-8. */
818 if (convert_to_utf8(mi, line, mi->charset.buf))
819 return 0; /* mi->input_error already set */
820
821 if (mi->use_scissors && is_scissors_line(line->buf)) {
822 int i;
823
824 strbuf_setlen(&mi->log_message, 0);
825 mi->header_stage = 1;
826
827 /*
828 * We may have already read "secondary headers"; purge
829 * them to give ourselves a clean restart.
830 */
831 for (i = 0; i < ARRAY_SIZE(header); i++) {
832 if (mi->s_hdr_data[i])
833 strbuf_release(mi->s_hdr_data[i]);
834 FREE_AND_NULL(mi->s_hdr_data[i]);
835 }
836 return 0;
837 }
838
839 if (patchbreak(line)) {
840 if (mi->message_id)
841 strbuf_addf(&mi->log_message,
842 "Message-ID: %s\n", mi->message_id);
843 return 1;
844 }
845
846 strbuf_addbuf(&mi->log_message, line);
847 return 0;
848}
849
850static void handle_patch(struct mailinfo *mi, const struct strbuf *line)

Callers 1

handle_filterFunction · 0.70

Calls 9

strbuf_setlenFunction · 0.85
strbuf_releaseFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_addbufFunction · 0.85
check_inbody_headerFunction · 0.70
convert_to_utf8Function · 0.70
is_scissors_lineFunction · 0.70
patchbreakFunction · 0.70

Tested by

no test coverage detected