@@ -882,6 +882,7 @@ LIB_OBJS += exec-cmd.o
LIB_OBJS += fetch-negotiator.o
LIB_OBJS += fetch-pack.o
LIB_OBJS += fmt-merge-msg.o
+LIB_OBJS += format-support.o
LIB_OBJS += fsck.o
LIB_OBJS += fsmonitor.o
LIB_OBJS += gettext.o
new file mode 100644
@@ -0,0 +1,43 @@
+#include "diff.h"
+#include "log-tree.h"
+#include "color.h"
+#include "format-support.h"
+
+static int istitlechar(char c)
+{
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') || c == '.' || c == '_';
+}
+
+void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len)
+{
+ char *r = xmemdupz(msg, len);
+ size_t trimlen;
+ size_t start_len = sb->len;
+ int space = 2;
+ int i;
+
+ for (i = 0; i < len; i++) {
+ if (r[i] == '\n')
+ r[i] = ' ';
+ if (istitlechar(r[i])) {
+ if (space == 1)
+ strbuf_addch(sb, '-');
+ space = 0;
+ strbuf_addch(sb, r[i]);
+ if (r[i] == '.')
+ while (r[i+1] == '.')
+ i++;
+ } else
+ space |= 1;
+ }
+ free(r);
+
+ /* trim any trailing '.' or '-' characters */
+ trimlen = 0;
+ while (sb->len - trimlen > start_len &&
+ (sb->buf[sb->len - 1 - trimlen] == '.'
+ || sb->buf[sb->len - 1 - trimlen] == '-'))
+ trimlen++;
+ strbuf_remove(sb, sb->len - trimlen, trimlen);
+}
new file mode 100644
@@ -0,0 +1,6 @@
+#ifndef FORMAT_SUPPORT_H
+#define FORMAT_SUPPORT_H
+
+void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len);
+
+#endif /* FORMAT_SUPPORT_H */
@@ -12,6 +12,7 @@
#include "reflog-walk.h"
#include "gpg-interface.h"
#include "trailer.h"
+#include "format-support.h"
static char *user_format;
static struct cmt_fmt_map {
@@ -833,45 +834,6 @@ static void parse_commit_header(struct format_commit_context *context)
context->commit_header_parsed = 1;
}
-static int istitlechar(char c)
-{
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
- (c >= '0' && c <= '9') || c == '.' || c == '_';
-}
-
-static void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len)
-{
- char *r = xmemdupz(msg, len);
- size_t trimlen;
- size_t start_len = sb->len;
- int space = 2;
- int i;
-
- for (i = 0; i < len; i++) {
- if (r[i] == '\n')
- r[i] = ' ';
- if (istitlechar(r[i])) {
- if (space == 1)
- strbuf_addch(sb, '-');
- space = 0;
- strbuf_addch(sb, r[i]);
- if (r[i] == '.')
- while (r[i+1] == '.')
- i++;
- } else
- space |= 1;
- }
- free(r);
-
- /* trim any trailing '.' or '-' characters */
- trimlen = 0;
- while (sb->len - trimlen > start_len &&
- (sb->buf[sb->len - 1 - trimlen] == '.'
- || sb->buf[sb->len - 1 - trimlen] == '-'))
- trimlen++;
- strbuf_remove(sb, sb->len - trimlen, trimlen);
-}
-
const char *format_subject(struct strbuf *sb, const char *msg,
const char *line_separator)
{