[PATCH] generate a valid rfc2047 mail header for multi-line subject.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is still a problem that git-am will lost the line break.
It's not easy to retain it, but as the first step, we can generate
a valid rfc2047 header now.
---
 pretty.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/pretty.c b/pretty.c
index 8549934..f18a38d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -249,6 +249,33 @@ needquote:
 	strbuf_addstr(sb, "?=");
 }
 
+static void add_rfc2047_multiline(struct strbuf *sb, const char *line, int len,
+                       const char *encoding)
+{
+	int first = 1;
+	char *mline = xmemdupz(line, len);
+	const char *cline = mline;
+	int offset = 0, linelen = 0;
+        for (;;) {
+                linelen = get_one_line(cline);
+
+                cline += linelen;
+
+                if (!linelen)
+                        break;
+		
+		if (!first)
+			strbuf_addf(sb, "\n ");
+
+		offset = *(cline -1) == '\n'; 
+
+		add_rfc2047(sb, cline-linelen, linelen-offset, encoding);
+		first = 0;
+
+        }
+	free(mline);
+}
+
 void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
 		  const char *line, enum date_mode dmode,
 		  const char *encoding)
@@ -1115,7 +1142,7 @@ void pp_title_line(enum cmit_fmt fmt,
 	strbuf_grow(sb, title.len + 1024);
 	if (subject) {
 		strbuf_addstr(sb, subject);
-		add_rfc2047(sb, title.buf, title.len, encoding);
+		add_rfc2047_multiline(sb, title.buf, title.len, encoding);
 	} else {
 		strbuf_addbuf(sb, &title);
 	}
-- 
1.7.4.52.g00e6e.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]