{"thread":{"id":"40142","subject":"Minor annoyance with 'git interpret-trailers'","startedAt":"2015-08-20T16:37:28Z","lastAt":"2015-08-21T07:01:34Z","messageCount":4,"participants":["Matthieu Moy","Christian Couder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"268373","messageId":"vpqy4h5ud9z.fsf@anie.imag.fr","threadId":"40142","inReplyTo":null,"subject":"Minor annoyance with 'git interpret-trailers'","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-08-20T16:37:28Z","receivedAt":"2015-08-20T16:37:28Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Hi,\n\nI use 'git interpret-trailers' as a commit-msg hook to add a\nSigned-off-by in a repository.\n\nWhen used in a one-line commit message formatted like\n'foo: do something', the command interprets the one-line summary as a\ntrailer, and inserts my Signed-off-by after it, without a blank line:\n\n    foo: do something\n    Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n\nThis breaks the convention \"One summary line, one blank line, and then\nbody\", and shows my sign-off in the output of \"git log --oneline\" :-(.\n\nI think the behavior \"don't insert a newline if the last line looks like\na trailer\" should be disabled when the message is a one-liner.\n\nCheers,\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"268376","messageId":"CAP8UFD0YcBdAfMJxc2bQD_zTp+kPk2L2sQfWYzTDn+trFk+DMA@mail.gmail.com","threadId":"40142","inReplyTo":"vpqy4h5ud9z.fsf@anie.imag.fr","subject":"Re: Minor annoyance with 'git interpret-trailers'","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-08-20T16:53:18Z","receivedAt":"2015-08-20T16:53:18Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thu, Aug 20, 2015 at 6:37 PM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Hi,\n>\n> I use 'git interpret-trailers' as a commit-msg hook to add a\n> Signed-off-by in a repository.\n>\n> When used in a one-line commit message formatted like\n> 'foo: do something', the command interprets the one-line summary as a\n> trailer, and inserts my Signed-off-by after it, without a blank line:\n>\n>     foo: do something\n>     Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n>\n> This breaks the convention \"One summary line, one blank line, and then\n> body\", and shows my sign-off in the output of \"git log --oneline\" :-(.\n>\n> I think the behavior \"don't insert a newline if the last line looks like\n> a trailer\" should be disabled when the message is a one-liner.\n\nYeah, I agree. I will take a look at fixing that soon.\n\nThanks for the report,\nChristian.\n"},{"id":"268390","messageId":"1440107955-26892-1-git-send-email-chriscool@tuxfamily.org","threadId":"40142","inReplyTo":"CAP8UFD0YcBdAfMJxc2bQD_zTp+kPk2L2sQfWYzTDn+trFk+DMA@mail.gmail.com","subject":"[PATCH] trailer: ignore first line of message","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-08-20T21:59:15Z","receivedAt":"2015-08-20T21:59:15Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"When looking for the start of the trailers in the message\nwe are passed, we should ignore the first line of the message.\n\nThe reason is that if we are passed a patch or commit message\nthen the first line should be the patch title.\nIf we are passed only trailers we can expect that they start\nwith an empty line that can be ignored too.\n\nThis way we can properly process commit messages that have\nonly one line with something that looks like a trailer, for\nexample like \"area of code: change we made\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t7513-interpret-trailers.sh | 15 ++++++++++++++-\n trailer.c                     |  3 ++-\n 2 files changed, 16 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh\nindex bd0ab46..f7ebc5e 100755\n--- a/t/t7513-interpret-trailers.sh\n+++ b/t/t7513-interpret-trailers.sh\n@@ -93,12 +93,25 @@ test_expect_success 'with config option on the command line' '\n \t\tAcked-by: Johan\n \t\tReviewed-by: Peff\n \tEOF\n-\techo \"Acked-by: Johan\" |\n+\t{ echo; echo \"Acked-by: Johan\"; } |\n \tgit -c \"trailer.Acked-by.ifexists=addifdifferent\" interpret-trailers \\\n \t\t--trailer \"Reviewed-by: Peff\" --trailer \"Acked-by: Johan\" >actual &&\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'with message that contains only a title' '\n+\tcat >expected <<-\\EOF &&\n+\t\tarea: change\n+\n+\t\tReviewed-by: Peff\n+\t\tAcked-by: Johan\n+\tEOF\n+\techo \"area: change\" |\n+\tgit interpret-trailers --trailer \"Reviewed-by: Peff\" \\\n+\t\t--trailer \"Acked-by: Johan\" >actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_expect_success 'with config setup' '\n \tgit config trailer.ack.key \"Acked-by: \" &&\n \tcat >expected <<-\\EOF &&\ndiff --git a/trailer.c b/trailer.c\nindex 4b14a56..af80b8e 100644\n--- a/trailer.c\n+++ b/trailer.c\n@@ -740,8 +740,9 @@ static int find_trailer_start(struct strbuf **lines, int count)\n \t/*\n \t * Get the start of the trailers by looking starting from the end\n \t * for a line with only spaces before lines with one separator.\n+\t * The start cannot be the first line.\n \t */\n-\tfor (start = count - 1; start >= 0; start--) {\n+\tfor (start = count - 1; start >= 1; start--) {\n \t\tif (lines[start]->buf[0] == comment_line_char)\n \t\t\tcontinue;\n \t\tif (contains_only_spaces(lines[start]->buf)) {\n-- \n2.5.0.400.gff86faf.dirty\n"},{"id":"268401","messageId":"vpqk2sprupd.fsf@anie.imag.fr","threadId":"40142","inReplyTo":"1440107955-26892-1-git-send-email-chriscool@tuxfamily.org","subject":"Re: [PATCH] trailer: ignore first line of message","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-08-21T07:01:34Z","receivedAt":"2015-08-21T07:01:34Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Christian Couder <christian.couder@gmail.com> writes:\n\n> When looking for the start of the trailers in the message\n> we are passed, we should ignore the first line of the message.\n\nThanks, this fixes my issue.\n\nThere's one more corner-case I've just thought of:\n\ngit commit -m 'place of\ncode: change we made'\n\n(with the line break)\n\nGit considers this message as a summary line broken in the middle. \"git\nlog --oneline\" shows it as a one-liner, as if it were\n'place of code: change we made'.\n\nEven with your patch, the trailer is added without a blank line, and\nrenders on the subject line in `git log --oneline`. My command above\nwith a commit-msg hook outputs:\n\n[master 86f32d5] place of: code: change we made Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n\n(on a single line)\n\nI do not care deeply, but you may want to let interpret-trailers deal\nwith this case too.\n\nThanks,\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}