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 <gitster@pobox.com>

Junio C Hamano committed Oct 17, 2012 at 20:48 UTC 212620fe7e74f6bd4a30a5a39d7c7b3f685ef888
2 files changed +14 -4
log-tree.c
+4 -2
@@ -672,12 +672,14 @@ void show_log(struct rev_info *opt)
672 ctx.reflog_info = opt->reflog_info;
673 ctx.fmt = opt->commit_format;
674 pretty_print_commit(&ctx, commit, &msgbuf);
675 +
676 + if (opt->add_signoff)
677 + append_signoff(&msgbuf, opt->add_signoff);
678 +
679 if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
680 ctx.notes_message && *ctx.notes_message)
681 strbuf_addstr(&msgbuf, ctx.notes_message);
682
679 - if (opt->add_signoff)
680 - append_signoff(&msgbuf, opt->add_signoff);
683 if (opt->show_log_size) {
684 printf("log size %i\n", (int)msgbuf.len);
685 graph_show_oneline(opt->graph);
t/t4014-format-patch.sh
+10 -2
@@ -616,8 +616,16 @@ test_expect_success 'format-patch --in-reply-to' '
616 '
617
618 test_expect_success 'format-patch --signoff' '
619 - git format-patch -1 --signoff --stdout |
620 - grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
619 + git format-patch -1 --signoff --stdout >out &&
620 + grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" out
621 +'
622 +
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
627 + ! sed "/^Signed-off-by: /q" out | grep "test message" &&
628 + sed "1,/^Signed-off-by: /d" out | grep "test message"
629 '
630
631 echo "fatal: --name-only does not make sense" > expect.name-only