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 <gitster@pobox.com>
Junio C Hamano committed
Oct 17, 2012 at 21:27 UTC
bd1470b8cb0cfb42c7de3b9084cdd8ae53aa1d4c
3 files changed
+17
-6
log-tree.c
+11
-4
@@ -677,8 +677,13 @@ void show_log(struct rev_info *opt)
677
append_signoff(&msgbuf, opt->add_signoff);
678
679
if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
680
- ctx.notes_message && *ctx.notes_message)
680
+ ctx.notes_message && *ctx.notes_message) {
681
+ if (ctx.fmt == CMIT_FMT_EMAIL) {
682
+ strbuf_addstr(&msgbuf, "---\n");
683
+ opt->shown_dashes = 1;
684
+ }
685
strbuf_addstr(&msgbuf, ctx.notes_message);
686
+ }
687
688
if (opt->show_log_size) {
689
printf("log size %i\n", (int)msgbuf.len);
@@ -710,6 +715,7 @@ void show_log(struct rev_info *opt)
715
716
int log_tree_diff_flush(struct rev_info *opt)
717
{
718
+ opt->shown_dashes = 0;
719
diffcore_std(&opt->diffopt);
720
721
if (diff_queue_is_empty()) {
@@ -737,10 +743,11 @@ int log_tree_diff_flush(struct rev_info *opt)
743
opt->diffopt.output_prefix_data);
744
fwrite(msg->buf, msg->len, 1, stdout);
745
}
740
- if ((pch & opt->diffopt.output_format) == pch) {
741
- printf("---");
746
+ if (!opt->shown_dashes) {
747
+ if ((pch & opt->diffopt.output_format) == pch)
748
+ printf("---");
749
+ putchar('\n');
750
}
743
- putchar('\n');
751
}
752
}
753
diff_flush(&opt->diffopt);
revision.h
+1
@@ -111,6 +111,7 @@ struct rev_info {
111
112
/* Format info */
113
unsigned int shown_one:1,
114
+ shown_dashes:1,
115
show_merge:1,
116
show_notes:1,
117
show_notes_given:1,
t/t4014-format-patch.sh
+5
-2
@@ -623,9 +623,12 @@ test_expect_success 'format-patch --signoff' '
623
test_expect_success 'format-patch --notes --signoff' '
624
git notes --ref test add -m "test message" HEAD &&
625
git format-patch -1 --signoff --stdout --notes=test >out &&
626
- # Notes message must come after S-o-b
626
+ # Three dashes must come after S-o-b
627
! sed "/^Signed-off-by: /q" out | grep "test message" &&
628
- sed "1,/^Signed-off-by: /d" out | grep "test message"
628
+ sed "1,/^Signed-off-by: /d" out | grep "test message" &&
629
+ # Notes message must come after three dashes
630
+ ! sed "/^---$/q" out | grep "test message" &&
631
+ sed "1,/^---$/d" out | grep "test message"
632
'
633
634
echo "fatal: --name-only does not make sense" > expect.name-only