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

Function format_sanitized_subject

pretty.c:947–974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945}
946
947void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len)
948{
949 size_t trimlen;
950 size_t start_len = sb->len;
951 int space = 2;
952 int i;
953
954 for (i = 0; i < len; i++) {
955 if (istitlechar(msg[i])) {
956 if (space == 1)
957 strbuf_addch(sb, '-');
958 space = 0;
959 strbuf_addch(sb, msg[i]);
960 if (msg[i] == '.')
961 while (msg[i+1] == '.')
962 i++;
963 } else
964 space |= 1;
965 }
966
967 /* trim any trailing '.' or '-' characters */
968 trimlen = 0;
969 while (sb->len - trimlen > start_len &&
970 (sb->buf[sb->len - 1 - trimlen] == '.'
971 || sb->buf[sb->len - 1 - trimlen] == '-'))
972 trimlen++;
973 strbuf_remove(sb, sb->len - trimlen, trimlen);
974}
975
976const char *format_subject(struct strbuf *sb, const char *msg,
977 const char *line_separator)

Callers 3

grab_sub_body_contentsFunction · 0.85
format_commit_oneFunction · 0.85
fmt_output_subjectFunction · 0.85

Calls 3

istitlecharFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_removeFunction · 0.85

Tested by

no test coverage detected