[PATCH/RFC 2/2] format-patch: show notes as message after the ---

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

 



When requesting notes with "--notes", "format-patch" produces notes
within the commit message which "am" misunderstands as being part of the
message.

Change this so that notes are displayed after an additional "---". Any
"am" (old or new) will ignore that, so that it is a safe place for
additional comments:

Log message
"---"
notes
"---"
diffstat
patch

(The first "---" appears only when there is a note, of course.)

Later on (say with "--format-notes") the output format can be changed
easily to accomodate a future "am" which knows how to create notes from
such patches.

Signed-off-by: Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx>
---
Reducing the output format to one "---" only is not only complicated (the notes
separator is generated in a quite different place from the patch separator)
but also unnecessary (am reads the patch anyways) and not even preferable (to
give a clear separation of the parts).
---
 builtin/log.c |    4 +++-
 notes.c       |    2 ++
 notes.h       |    3 +++
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 5e71caa..67aed94 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1159,8 +1159,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
 		DIFF_OPT_SET(&rev.diffopt, BINARY);
 
-	if (rev.show_notes)
+	if (rev.show_notes) {
 		init_display_notes(&rev.notes_opt);
+		rev.show_notes = NOTES_DASH;
+	}
 
 	if (!use_stdout)
 		output_directory = set_outdir(prefix, output_directory);
diff --git a/notes.c b/notes.c
index a013c1b..b8b737e 100644
--- a/notes.c
+++ b/notes.c
@@ -1233,6 +1233,8 @@ void format_note(struct notes_tree *t, const unsigned char *object_sha1,
 	if (msglen && msg[msglen - 1] == '\n')
 		msglen--;
 
+	if (flags & NOTES_DASH)
+		strbuf_addstr(sb, "---\n");
 	if (flags & NOTES_SHOW_HEADER) {
 		const char *ref = t->ref;
 		if (!ref || !strcmp(ref, GIT_NOTES_DEFAULT_REF)) {
diff --git a/notes.h b/notes.h
index 81d16e3..17150d5 100644
--- a/notes.h
+++ b/notes.h
@@ -238,6 +238,7 @@ void free_notes(struct notes_tree *t);
 /* Flags controlling how notes are formatted */
 #define NOTES_SHOW_HEADER 1
 #define NOTES_INDENT 2
+#define NOTES_DASH 4
 #define NOTES_DEFAULT (NOTES_SHOW_HEADER | NOTES_INDENT)
 
 /*
@@ -284,6 +285,8 @@ void init_display_notes(struct display_notes_opt *opt);
  *
  * - NOTES_INDENT: indent the notes by 4 places
  *
+ * - NOTES_DASH: prepend a "---" line
+ *
  * You *must* call init_display_notes() before using this function.
  */
 void format_display_notes(const unsigned char *object_sha1,
-- 
1.7.5.270.gafca7

--
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]