From e297cf5aff0264c16b6c325c0beab71bc04cd496 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 17:12:55 -0700 Subject: [PATCH 01/12] pretty: remove reencode_commit_message() This function has only two callsites, and is a thin wrapper whose usefulness is dubious. When the caller needs to learn the log output encoding, it should be able to do so by directly calling get_log_output_encoding() and calling the underlying logmsg_reencode() with it. Signed-off-by: Junio C Hamano --- builtin/blame.c | 5 +++-- commit.h | 2 -- pretty.c | 13 ++----------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/builtin/blame.c b/builtin/blame.c index c27ef21c23..cfae569905 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1425,7 +1425,7 @@ static void get_commit_info(struct commit *commit, int detailed) { int len; - const char *subject; + const char *subject, *encoding; char *reencoded, *message; static char author_name[1024]; static char author_mail[1024]; @@ -1446,7 +1446,8 @@ static void get_commit_info(struct commit *commit, die("Cannot read commit %s", sha1_to_hex(commit->object.sha1)); } - reencoded = reencode_commit_message(commit, NULL); + encoding = get_log_output_encoding(); + reencoded = logmsg_reencode(commit, encoding); message = reencoded ? reencoded : commit->buffer; ret->author = author_name; ret->author_mail = author_mail; diff --git a/commit.h b/commit.h index 9f2131318d..a822af8c8d 100644 --- a/commit.h +++ b/commit.h @@ -99,8 +99,6 @@ extern int has_non_ascii(const char *text); struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ extern char *logmsg_reencode(const struct commit *commit, const char *output_encoding); -extern char *reencode_commit_message(const struct commit *commit, - const char **encoding_p); extern void get_commit_format(const char *arg, struct rev_info *); extern const char *format_subject(struct strbuf *sb, const char *msg, const char *line_separator); diff --git a/pretty.c b/pretty.c index 8b1ea9ffad..c311a68fc4 100644 --- a/pretty.c +++ b/pretty.c @@ -1341,16 +1341,6 @@ void pp_remainder(const struct pretty_print_context *pp, } } -char *reencode_commit_message(const struct commit *commit, const char **encoding_p) -{ - const char *encoding; - - encoding = get_log_output_encoding(); - if (encoding_p) - *encoding_p = encoding; - return logmsg_reencode(commit, encoding); -} - void pretty_print_commit(const struct pretty_print_context *pp, const struct commit *commit, struct strbuf *sb) @@ -1367,7 +1357,8 @@ void pretty_print_commit(const struct pretty_print_context *pp, return; } - reencoded = reencode_commit_message(commit, &encoding); + encoding = get_log_output_encoding(); + reencoded = logmsg_reencode(commit, encoding); if (reencoded) { msg = reencoded; } From 76141e2e6280101362c3c5ddb22699b6f0458100 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 21:41:54 -0700 Subject: [PATCH 02/12] format_note(): simplify API We either stuff the notes message without modification for %N userformat, or format it for human consumption. Using two bits is an overkill that does not benefit anybody. Signed-off-by: Junio C Hamano --- notes.c | 13 +++++++------ notes.h | 6 +----- pretty.c | 5 ++--- revision.c | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/notes.c b/notes.c index bc454e1eab..97097db9dc 100644 --- a/notes.c +++ b/notes.c @@ -1204,10 +1204,11 @@ void free_notes(struct notes_tree *t) * If the given notes_tree is NULL, the internal/default notes_tree will be * used instead. * - * 'flags' is a bitwise combination of the flags for format_display_notes. + * (raw != 0) gives the %N userformat; otherwise, the note message is given + * for human consumption. */ static void format_note(struct notes_tree *t, const unsigned char *object_sha1, - struct strbuf *sb, const char *output_encoding, int flags) + struct strbuf *sb, const char *output_encoding, int raw) { static const char utf8[] = "utf-8"; const unsigned char *sha1; @@ -1244,7 +1245,7 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1, if (msglen && msg[msglen - 1] == '\n') msglen--; - if (flags & NOTES_SHOW_HEADER) { + if (!raw) { const char *ref = t->ref; if (!ref || !strcmp(ref, GIT_NOTES_DEFAULT_REF)) { strbuf_addstr(sb, "\nNotes:\n"); @@ -1260,7 +1261,7 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1, for (msg_p = msg; msg_p < msg + msglen; msg_p += linelen + 1) { linelen = strchrnul(msg_p, '\n') - msg_p; - if (flags & NOTES_INDENT) + if (!raw) strbuf_addstr(sb, " "); strbuf_add(sb, msg_p, linelen); strbuf_addch(sb, '\n'); @@ -1270,13 +1271,13 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1, } void format_display_notes(const unsigned char *object_sha1, - struct strbuf *sb, const char *output_encoding, int flags) + struct strbuf *sb, const char *output_encoding, int raw) { int i; assert(display_notes_trees); for (i = 0; display_notes_trees[i]; i++) format_note(display_notes_trees[i], object_sha1, sb, - output_encoding, flags); + output_encoding, raw); } int copy_note(struct notes_tree *t, diff --git a/notes.h b/notes.h index 3592b19d2d..3324c486a1 100644 --- a/notes.h +++ b/notes.h @@ -237,10 +237,6 @@ void prune_notes(struct notes_tree *t, int flags); */ void free_notes(struct notes_tree *t); -/* Flags controlling how notes are formatted */ -#define NOTES_SHOW_HEADER 1 -#define NOTES_INDENT 2 - struct string_list; struct display_notes_opt { @@ -274,7 +270,7 @@ void init_display_notes(struct display_notes_opt *opt); * You *must* call init_display_notes() before using this function. */ void format_display_notes(const unsigned char *object_sha1, - struct strbuf *sb, const char *output_encoding, int flags); + struct strbuf *sb, const char *output_encoding, int raw); /* * Load the notes tree from each ref listed in 'refs'. The output is diff --git a/pretty.c b/pretty.c index c311a68fc4..735cf0fec3 100644 --- a/pretty.c +++ b/pretty.c @@ -1035,7 +1035,7 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder, case 'N': if (c->pretty_ctx->show_notes) { format_display_notes(commit->object.sha1, sb, - get_log_output_encoding(), 0); + get_log_output_encoding(), 1); return 1; } return 0; @@ -1419,8 +1419,7 @@ void pretty_print_commit(const struct pretty_print_context *pp, strbuf_addch(sb, '\n'); if (pp->show_notes) - format_display_notes(commit->object.sha1, sb, encoding, - NOTES_SHOW_HEADER | NOTES_INDENT); + format_display_notes(commit->object.sha1, sb, encoding, 0); free(reencoded); } diff --git a/revision.c b/revision.c index a09e60bedb..ddfba11ca8 100644 --- a/revision.c +++ b/revision.c @@ -2236,7 +2236,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt) if (!buf.len) strbuf_addstr(&buf, commit->buffer); format_display_notes(commit->object.sha1, &buf, - get_log_output_encoding(), 0); + get_log_output_encoding(), 1); } /* Find either in the commit object, or in the temporary */ From ddf333f66cb8b8647a40e5d39731eaf63ee9fd44 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 18:51:47 -0700 Subject: [PATCH 03/12] pretty: prepare notes message at a centralized place Instead of passing a boolean show_notes around, pass an optional string that is to be inserted after the log message proper is shown. Signed-off-by: Junio C Hamano --- commit.h | 2 +- log-tree.c | 14 +++++++++++++- pretty.c | 9 ++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/commit.h b/commit.h index a822af8c8d..7b43e45017 100644 --- a/commit.h +++ b/commit.h @@ -86,7 +86,7 @@ struct pretty_print_context { enum date_mode date_mode; unsigned date_mode_explicit:1; int need_8bit_cte; - int show_notes; + char *notes_message; struct reflog_walk_info *reflog_info; const char *output_encoding; }; diff --git a/log-tree.c b/log-tree.c index c894930c18..84e9f5bb66 100644 --- a/log-tree.c +++ b/log-tree.c @@ -540,7 +540,6 @@ void show_log(struct rev_info *opt) struct pretty_print_context ctx = {0}; opt->loginfo = NULL; - ctx.show_notes = opt->show_notes; if (!opt->verbose_header) { graph_show_commit(opt->graph); @@ -648,6 +647,18 @@ void show_log(struct rev_info *opt) if (!commit->buffer) return; + if (opt->show_notes) { + int raw; + struct strbuf notebuf = STRBUF_INIT; + + raw = (opt->commit_format == CMIT_FMT_USERFORMAT); + format_display_notes(commit->object.sha1, ¬ebuf, + get_log_output_encoding(), raw); + ctx.notes_message = notebuf.len + ? strbuf_detach(¬ebuf, NULL) + : xcalloc(1, 1); + } + /* * And then the pretty-printed message itself */ @@ -689,6 +700,7 @@ void show_log(struct rev_info *opt) } strbuf_release(&msgbuf); + free(ctx.notes_message); } int log_tree_diff_flush(struct rev_info *opt) diff --git a/pretty.c b/pretty.c index 735cf0fec3..a53eb532aa 100644 --- a/pretty.c +++ b/pretty.c @@ -1033,9 +1033,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder, } return 0; /* unknown %g placeholder */ case 'N': - if (c->pretty_ctx->show_notes) { - format_display_notes(commit->object.sha1, sb, - get_log_output_encoding(), 1); + if (c->pretty_ctx->notes_message) { + strbuf_addstr(sb, c->pretty_ctx->notes_message); return 1; } return 0; @@ -1418,8 +1417,8 @@ void pretty_print_commit(const struct pretty_print_context *pp, if (pp->fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body) strbuf_addch(sb, '\n'); - if (pp->show_notes) - format_display_notes(commit->object.sha1, sb, encoding, 0); + if (pp->notes_message && *pp->notes_message) + strbuf_addstr(sb, pp->notes_message); free(reencoded); } From 5a664cf2c76ed83166f5f3ce7385e3cb058e8834 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 19:02:46 -0700 Subject: [PATCH 04/12] pretty_print_commit(): do not append notes message The only case pretty_print_commit() appends notes message to the log message taken from the commit is when show_log() calls it with the notes_message field set, and the output format is not the userformat (i.e. when substituting "%N"). No other users of this function sets this field in the pretty_print_context, as can be easily verified in the previous step. Hoist the code to append the notes message to the caller. Up to this point, no functionality change is intended. Signed-off-by: Junio C Hamano --- log-tree.c | 3 +++ pretty.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/log-tree.c b/log-tree.c index 84e9f5bb66..e7e08f42eb 100644 --- a/log-tree.c +++ b/log-tree.c @@ -672,6 +672,9 @@ void show_log(struct rev_info *opt) ctx.reflog_info = opt->reflog_info; ctx.fmt = opt->commit_format; pretty_print_commit(&ctx, commit, &msgbuf); + if ((ctx.fmt != CMIT_FMT_USERFORMAT) && + ctx.notes_message && *ctx.notes_message) + strbuf_addstr(&msgbuf, ctx.notes_message); if (opt->add_signoff) append_signoff(&msgbuf, opt->add_signoff); diff --git a/pretty.c b/pretty.c index a53eb532aa..1925e9c3e4 100644 --- a/pretty.c +++ b/pretty.c @@ -1417,9 +1417,6 @@ void pretty_print_commit(const struct pretty_print_context *pp, if (pp->fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body) strbuf_addch(sb, '\n'); - if (pp->notes_message && *pp->notes_message) - strbuf_addstr(sb, pp->notes_message); - free(reencoded); } From 212620fe7e74f6bd4a30a5a39d7c7b3f685ef888 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 20:48:25 -0700 Subject: [PATCH 05/12] format-patch: append --signature after notes When appending a new signature with "format-patch --signature", if the "--notes" option is also in effect, the location of the new signature (and if the signature should be added in the first place) should be decided using the contents of the original commit log message, before the message from the notes is added. Signed-off-by: Junio C Hamano --- log-tree.c | 6 ++++-- t/t4014-format-patch.sh | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/log-tree.c b/log-tree.c index e7e08f42eb..4390b117e3 100644 --- a/log-tree.c +++ b/log-tree.c @@ -672,12 +672,14 @@ void show_log(struct rev_info *opt) ctx.reflog_info = opt->reflog_info; ctx.fmt = opt->commit_format; pretty_print_commit(&ctx, commit, &msgbuf); + + if (opt->add_signoff) + append_signoff(&msgbuf, opt->add_signoff); + if ((ctx.fmt != CMIT_FMT_USERFORMAT) && ctx.notes_message && *ctx.notes_message) strbuf_addstr(&msgbuf, ctx.notes_message); - if (opt->add_signoff) - append_signoff(&msgbuf, opt->add_signoff); if (opt->show_log_size) { printf("log size %i\n", (int)msgbuf.len); graph_show_oneline(opt->graph); diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 959aa26ef5..bea63814e6 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -616,8 +616,16 @@ test_expect_success 'format-patch --in-reply-to' ' ' test_expect_success 'format-patch --signoff' ' - git format-patch -1 --signoff --stdout | - grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" + git format-patch -1 --signoff --stdout >out && + grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" out +' + +test_expect_success 'format-patch --notes --signoff' ' + git notes --ref test add -m "test message" HEAD && + git format-patch -1 --signoff --stdout --notes=test >out && + # Notes message must come after S-o-b + ! sed "/^Signed-off-by: /q" out | grep "test message" && + sed "1,/^Signed-off-by: /d" out | grep "test message" ' echo "fatal: --name-only does not make sense" > expect.name-only From bd1470b8cb0cfb42c7de3b9084cdd8ae53aa1d4c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 21:27:22 -0700 Subject: [PATCH 06/12] format-patch --notes: show notes after three-dashes When inserting the note after the commit log message to format-patch output, add three dashes before the note. Record the fact that we did so in the rev_info and omit showing duplicated three dashes in the usual codepath that is used when notes are not being shown. Signed-off-by: Junio C Hamano --- log-tree.c | 15 +++++++++++---- revision.h | 1 + t/t4014-format-patch.sh | 7 +++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/log-tree.c b/log-tree.c index 4390b117e3..712a22b19b 100644 --- a/log-tree.c +++ b/log-tree.c @@ -677,8 +677,13 @@ void show_log(struct rev_info *opt) append_signoff(&msgbuf, opt->add_signoff); if ((ctx.fmt != CMIT_FMT_USERFORMAT) && - ctx.notes_message && *ctx.notes_message) + ctx.notes_message && *ctx.notes_message) { + if (ctx.fmt == CMIT_FMT_EMAIL) { + strbuf_addstr(&msgbuf, "---\n"); + opt->shown_dashes = 1; + } strbuf_addstr(&msgbuf, ctx.notes_message); + } if (opt->show_log_size) { printf("log size %i\n", (int)msgbuf.len); @@ -710,6 +715,7 @@ void show_log(struct rev_info *opt) int log_tree_diff_flush(struct rev_info *opt) { + opt->shown_dashes = 0; diffcore_std(&opt->diffopt); if (diff_queue_is_empty()) { @@ -737,10 +743,11 @@ int log_tree_diff_flush(struct rev_info *opt) opt->diffopt.output_prefix_data); fwrite(msg->buf, msg->len, 1, stdout); } - if ((pch & opt->diffopt.output_format) == pch) { - printf("---"); + if (!opt->shown_dashes) { + if ((pch & opt->diffopt.output_format) == pch) + printf("---"); + putchar('\n'); } - putchar('\n'); } } diff_flush(&opt->diffopt); diff --git a/revision.h b/revision.h index a95bd0b3f3..059bfff812 100644 --- a/revision.h +++ b/revision.h @@ -111,6 +111,7 @@ struct rev_info { /* Format info */ unsigned int shown_one:1, + shown_dashes:1, show_merge:1, show_notes:1, show_notes_given:1, diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index bea63814e6..9750ba6996 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -623,9 +623,12 @@ test_expect_success 'format-patch --signoff' ' test_expect_success 'format-patch --notes --signoff' ' git notes --ref test add -m "test message" HEAD && git format-patch -1 --signoff --stdout --notes=test >out && - # Notes message must come after S-o-b + # Three dashes must come after S-o-b ! sed "/^Signed-off-by: /q" out | grep "test message" && - sed "1,/^Signed-off-by: /d" out | grep "test message" + sed "1,/^Signed-off-by: /d" out | grep "test message" && + # Notes message must come after three dashes + ! sed "/^---$/q" out | grep "test message" && + sed "1,/^---$/d" out | grep "test message" ' echo "fatal: --name-only does not make sense" > expect.name-only From e422c0cf1cd76e9c7957b46b317d1d8fabcdd8ee Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 19 Oct 2012 13:01:05 -0700 Subject: [PATCH 07/12] Documentation: decribe format-patch --notes Even though I coded this, I am not sure what use scenarios would benefit from this option, so the description is unnecessarily negative at this moment. People who do want to use this feature need to come up with a more plausible use case and replace it. Signed-off-by: Junio C Hamano --- Documentation/git-format-patch.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 6d43f56279..066dc8be45 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -20,7 +20,7 @@ SYNOPSIS [--ignore-if-in-upstream] [--subject-prefix=Subject-Prefix] [--to=] [--cc=] - [--cover-letter] [--quiet] + [--cover-letter] [--quiet] [--notes[=]] [] [ | ] @@ -191,6 +191,19 @@ will want to ensure that threading is disabled for `git send-email`. containing the shortlog and the overall diffstat. You can fill in a description in the file before sending it out. +--notes[=]:: + Append the notes (see linkgit:git-notes[1]) for the commit + after the three-dash line. ++ +The expected use case of this is to write supporting explanation for +the commit that does not belong to the commit log message proper +when (or after) you create the commit, and include it in your patch +submission. But if you can plan ahead and write it down, there may +not be a good reason not to write it in your commit message, and if +you can't, you can always edit the output of format-patch before +sending it out, so the practical value of this option is somewhat +dubious, unless your workflow is broken. + --[no]-signature=:: Add a signature to each message produced. Per RFC 3676 the signature is separated from the body by a line with '-- ' on it. If the From 76323c67b7729076e4f905f6d227329a47e6443f Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 21 Oct 2012 22:34:07 +0100 Subject: [PATCH 08/12] Doc SubmittingPatches: Mention --notes option after "cover letter" The git format-patch --notes option can now insert the commit notes after the three dashes. Mention this after the regular cover letter guidance for submitting patches. Signed-off-by: Philip Oakley Signed-off-by: Jeff King --- Documentation/SubmittingPatches | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 0dbf2c9843..3d8b2fe4d1 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -179,7 +179,8 @@ message starts, you can put a "From: " line to name that person. You often want to add additional explanation about the patch, other than the commit message itself. Place such "cover letter" -material between the three dash lines and the diffstat. +material between the three dash lines and the diffstat. Git-notes +can also be inserted using the `--notes` option. Do not attach the patch as a MIME attachment, compressed or not. Do not let your e-mail client send quoted-printable. Do not let From e39b307d09c41ff660f4ddfcecbcb08177fcd4f3 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 21 Oct 2012 22:34:09 +0100 Subject: [PATCH 09/12] Doc notes: Include the format-patch --notes option git format-patch gained a --notes option. Tell the notes user. Signed-off-by: Philip Oakley Signed-off-by: Jeff King --- Documentation/git-notes.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt index b95aafae2d..46ef0466be 100644 --- a/Documentation/git-notes.txt +++ b/Documentation/git-notes.txt @@ -39,6 +39,10 @@ message stored in the commit object, the notes are indented like the message, after an unindented line saying "Notes ():" (or "Notes:" for `refs/notes/commits`). +Notes can also be added to patches prepared with `git format-patch` by +using the `--notes` option. Such notes are added as a patch commentary +after a three dash separator line. + To change which notes are shown by 'git log', see the "notes.displayRef" configuration in linkgit:git-log[1]. From 6454d9f166236965c84650f72ecdd17e309394d6 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 21 Oct 2012 22:34:10 +0100 Subject: [PATCH 10/12] Doc format-patch: clarify --notes use case Remove double negative, and include the repeat usage across versions of a patch series. Signed-off-by: Philip Oakley Signed-off-by: Jeff King --- Documentation/git-format-patch.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 066dc8be45..259dce4994 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -196,13 +196,12 @@ will want to ensure that threading is disabled for `git send-email`. after the three-dash line. + The expected use case of this is to write supporting explanation for -the commit that does not belong to the commit log message proper -when (or after) you create the commit, and include it in your patch -submission. But if you can plan ahead and write it down, there may -not be a good reason not to write it in your commit message, and if -you can't, you can always edit the output of format-patch before -sending it out, so the practical value of this option is somewhat -dubious, unless your workflow is broken. +the commit that does not belong to the commit log message proper, +and include it with the patch submission. While one can simply write +these explanations after `format-patch` has run but before sending, +keeping them as git notes allows them to be maintained between versions +of the patch series (but see the discussion of the `notes.rewrite` +configuration options in linkgit:git-notes[1] to use this workflow). --[no]-signature=:: Add a signature to each message produced. Per RFC 3676 the signature From d84cef1817be9615729b26e3965e8cb8da926dc5 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 21 Oct 2012 22:34:08 +0100 Subject: [PATCH 11/12] Doc User-Manual: Patch cover letter, three dashes, and --notes Show that git format-patch can have a cover letter, include patch commentary below the three dashes, and notes can also be included. Signed-off-by: Philip Oakley Signed-off-by: Jeff King --- Documentation/user-manual.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 85651b57ae..1b377dc207 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -1787,6 +1787,13 @@ $ git format-patch origin will produce a numbered series of files in the current directory, one for each patch in the current branch but not in origin/HEAD. +`git format-patch` can include an initial "cover letter". You can insert +commentary on individual patches after the three dash line which +`format-patch` places after the commit message but before the patch +itself. If you use `git notes` to track your cover letter material, +`git format-patch --notes` will include the commit's notes in a similar +manner. + You can then import these into your mail client and send them by hand. However, if you have a lot to send at once, you may prefer to use the linkgit:git-send-email[1] script to automate the process. From 1d34c50f132d2234bd70956ef99b2b94786d43dd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Nov 2012 10:09:07 -0800 Subject: [PATCH 12/12] format-patch: add a blank line between notes and diffstat The last line of the note text comes immediately before the diffstat block, making the latter unnecessarily harder to view. Signed-off-by: Junio C Hamano --- log-tree.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/log-tree.c b/log-tree.c index 712a22b19b..4f86defe32 100644 --- a/log-tree.c +++ b/log-tree.c @@ -727,15 +727,16 @@ int log_tree_diff_flush(struct rev_info *opt) } if (opt->loginfo && !opt->no_commit_id) { - /* When showing a verbose header (i.e. log message), - * and not in --pretty=oneline format, we would want - * an extra newline between the end of log and the - * output for readability. - */ show_log(opt); if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) && opt->verbose_header && opt->commit_format != CMIT_FMT_ONELINE) { + /* + * When showing a verbose header (i.e. log message), + * and not in --pretty=oneline format, we would want + * an extra newline between the end of log and the + * diff/diffstat output for readability. + */ int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH; if (opt->diffopt.output_prefix) { struct strbuf *msg = NULL; @@ -743,11 +744,21 @@ int log_tree_diff_flush(struct rev_info *opt) opt->diffopt.output_prefix_data); fwrite(msg->buf, msg->len, 1, stdout); } - if (!opt->shown_dashes) { - if ((pch & opt->diffopt.output_format) == pch) - printf("---"); - putchar('\n'); - } + + /* + * We may have shown three-dashes line early + * between notes and the log message, in which + * case we only want a blank line after the + * notes without (an extra) three-dashes line. + * Otherwise, we show the three-dashes line if + * we are showing the patch with diffstat, but + * in that case, there is no extra blank line + * after the three-dashes line. + */ + if (!opt->shown_dashes && + (pch & opt->diffopt.output_format) == pch) + printf("---"); + putchar('\n'); } } diff_flush(&opt->diffopt);