提交 6b2fbaaf 编写于 作者: K Kevin Ballard 提交者: Junio C Hamano

format-patch: Produce better output with --inline or --attach

This patch makes two small changes to improve the output of --inline
and --attach.

The first is to write a newline preceding the boundary. This is needed because
MIME defines the encapsulation boundary as including the preceding CRLF (or in
this case, just LF), so we should be writing one. Without this, the last
newline in the pre-diff content is consumed instead.

The second change is to always write the line termination character
(default: newline) even when using --inline or --attach. This is simply to
improve the aesthetics of the resulting message. When using --inline an email
client should render the resulting message identically to the non-inline
version. And when using --attach this adds a blank line preceding the
attachment in the email, which is visually attractive.
Signed-off-by: NKevin Ballard <kevin@sb.org>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 8cb070a4
...@@ -3223,11 +3223,10 @@ void diff_flush(struct diff_options *options) ...@@ -3223,11 +3223,10 @@ void diff_flush(struct diff_options *options)
if (output_format & DIFF_FORMAT_PATCH) { if (output_format & DIFF_FORMAT_PATCH) {
if (separator) { if (separator) {
putc(options->line_termination, options->file);
if (options->stat_sep) { if (options->stat_sep) {
/* attach patch instead of inline */ /* attach patch instead of inline */
fputs(options->stat_sep, options->file); fputs(options->stat_sep, options->file);
} else {
putc(options->line_termination, options->file);
} }
} }
......
...@@ -198,7 +198,7 @@ void log_write_email_headers(struct rev_info *opt, const char *name, ...@@ -198,7 +198,7 @@ void log_write_email_headers(struct rev_info *opt, const char *name,
extra_headers = subject_buffer; extra_headers = subject_buffer;
snprintf(buffer, sizeof(buffer) - 1, snprintf(buffer, sizeof(buffer) - 1,
"--%s%s\n" "\n--%s%s\n"
"Content-Type: text/x-patch;" "Content-Type: text/x-patch;"
" name=\"%s.diff\"\n" " name=\"%s.diff\"\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
......
...@@ -19,6 +19,8 @@ This is the second commit. ...@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 --- file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-) 3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2 delete mode 100644 file2
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit ...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++ file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-) 2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1 create mode 100644 file1
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
...@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit ...@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++ file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-) 3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3 create mode 100644 file3
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
......
...@@ -19,6 +19,8 @@ This is the second commit. ...@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 --- file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-) 3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2 delete mode 100644 file2
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit ...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++ file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-) 2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1 create mode 100644 file1
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
......
...@@ -17,6 +17,8 @@ Content-Transfer-Encoding: 8bit ...@@ -17,6 +17,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++ file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-) 3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3 create mode 100644 file3
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
......
...@@ -19,6 +19,8 @@ This is the second commit. ...@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 --- file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-) 3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2 delete mode 100644 file2
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit ...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++ file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-) 2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1 create mode 100644 file1
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
...@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit ...@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++ file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-) 3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3 create mode 100644 file3
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
......
...@@ -19,6 +19,8 @@ This is the second commit. ...@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 --- file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-) 3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2 delete mode 100644 file2
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit ...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++ file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-) 2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1 create mode 100644 file1
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
...@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit ...@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++ file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-) 3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3 create mode 100644 file3
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
......
...@@ -19,6 +19,8 @@ This is the second commit. ...@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 --- file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-) 3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2 delete mode 100644 file2
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit ...@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++ file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-) 2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1 create mode 100644 file1
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
......
...@@ -19,6 +19,8 @@ This is the second commit. ...@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 --- file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-) 3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2 delete mode 100644 file2
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
......
...@@ -17,6 +17,8 @@ Content-Transfer-Encoding: 8bit ...@@ -17,6 +17,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++ file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-) 3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3 create mode 100644 file3
--------------g-i-t--v-e-r-s-i-o-n --------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册