From: xzer <xiaozhu@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] generate a valid rfc2047 mail header for multi-line subject.
Date: Thu, 24 Feb 2011 00:34:54 +0900 [thread overview]
Message-ID: <AANLkTinf6P-erY-9p5WPWbK+uAf1hozvAutV0zPSpHGQ@mail.gmail.com> (raw)
In-Reply-To: <7vsjvfby0z.fsf@alter.siamese.dyndns.org>
2011/2/23 Junio C Hamano <gitster@pobox.com>:
> xzer <xiaozhu@gmail.com> writes:
>
>> Subject: Re: [PATCH] generate a valid rfc2047 mail header for multi-line subject.
>
> We prefer to have "[PATCH] subsystem: description without final full-stop" here.
>
>> There is still a problem that git-am will lost the line break.
>
> What does "still" refer to? It is unclear under what condition the
> command lose "the line break" (nor which line break you are refering to; I
> am guessing that you have a commit that begins with a multi-line paragraph
> and you are talking about line breaks between the lines in the first
> paragraph).
>
Yes, that is what I am refering, the line breaks in the first paragraph.
>> It's not easy to retain it, but as the first step, we can generate
>> a valid rfc2047 header now.
>
> Please describe what is broken (iow, "Given this sample input, we
> currently generate this output, which is not a valid rfc2047") and what
> the new output looks like ("Update pp_title_line() to generate this output
> instead.")
>
At present we can only concatenate the lines in the first paragraph so
that we can generate a valid rfc2047 mail, but we will lost the line breaks
after import the patch by git-am.
>> ---
>
> Missing sign-off with a real name.
>
I am sorry that I didn't find the document of submitting a patch until
yesterday, Thanks for your comment.
>> 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 (;;) {
>
> You seem to have indent that uses SPs instead of HT around here...
>
>> + linelen = get_one_line(cline);
>
> I can see you are trying to be careful not to let get_one_line() overstep
> past "len" the caller gave you by making a copy first, but is this
> overhead really necessary? After all we know in this static function that
> the caller is feeding the contents from a strbuf, which always have a
> terminating NUL (and that is why it is Ok that get_one_line() is not a
> counted string interface).
>
I am not sure that who will call this function in future, I think since there is
a argument as len, so I'd better to obey the function declare.
>> +
>> + 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);
>> +}
>
> So the general idea of this change (I am thinking aloud what should be in
> the updated commit log message as the problem description) is that:
>
> - We currently give an entire multi-line paragraph string to the
> add_rfc2047() function to be formatted as the title of the commit;
>
> - The add_rfc2047() functionjust passes "\n" through, without making it a
> folding whitespace followed by a newline, to help callers that want to
> use this function to produce a header line that is rfc 2822 conformant;
>
> - The patch introduces a new function add_rfc2047_multiline() that splits
> its input and performs line folding for such a caller (namely, the
> pp_title_line() function);
>
> - Another caller of add_rfc2047(), pp_user_info, is not changed, and it
> won't fold the name of the user that appear on the From: line.
>
> It is unclear if the last point is really the right thing to do, though.
> It is not a new problem that an author name that has a "\n" in it would
> break the output, but we probably would want to fix that case too here?
>
Your comment is just right for what I tried to do, I explained why I add a new
function for subject specially in the mail which replied to Jeff, I
want to remain
the line breaks after import the patch, so I think I need do something here
in future, it will be compatible with rfc2047 and also can be imported with
line breaks correctly. I don't know how yet, so I just want to left a
possibility.
So I introduce a new function for subject only.
xzer
next prev parent reply other threads:[~2011-02-23 15:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-14 8:09 [PATCH] generate a valid rfc2047 mail header for multi-line subject xzer
2011-02-22 20:43 ` Junio C Hamano
2011-02-23 8:08 ` Jeff King
2011-02-23 9:48 ` Jeff King
2011-02-23 9:50 ` [PATCH 1/3] strbuf: add fixed-length version of add_wrapped_text Jeff King
2011-02-23 9:58 ` [PATCH 2/3] format-patch: wrap long header lines Jeff King
2011-02-23 9:59 ` [PATCH 3/3] format-patch: rfc2047-encode newlines in headers Jeff King
2011-02-23 21:47 ` Junio C Hamano
2011-02-24 7:15 ` Jeff King
2011-02-23 15:16 ` [PATCH] generate a valid rfc2047 mail header for multi-line subject xzer
2011-02-23 16:35 ` Jeff King
2011-02-23 17:34 ` Junio C Hamano
2011-02-24 7:34 ` Jeff King
2011-02-23 15:34 ` xzer [this message]
2011-02-23 17:45 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTinf6P-erY-9p5WPWbK+uAf1hozvAutV0zPSpHGQ@mail.gmail.com \
--to=xiaozhu@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).