{"thread":{"id":"21824","subject":"[BUG?] git-merge appends extra string to user's message?","startedAt":"2009-12-02T10:20:30Z","lastAt":"2009-12-02T17:13:02Z","messageCount":4,"participants":["Nanako Shiraishi","Miklos Vajna","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"128993","messageId":"20091202192030.6117@nanako3.lavabit.com","threadId":"21824","inReplyTo":null,"subject":"[BUG?] git-merge appends extra string to user's message?","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-12-02T10:20:30Z","receivedAt":"2009-12-02T10:20:30Z","isPatch":false,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"When \"git merge\" is run with a message, it appends an extra message \nthat it would add if it were run without one. For example, when I \ntried to merge an early part of a side branch.\n\n% git merge -m \"Merge early part of side branch\" `git rev-parse side~2`\n% git show -s \ncommit 37217141e7519629353738d5e4e677a15096206f\nMerge: e68e646 a1d2374\nAuthor: しらいし ななこ <nanako3@lavabit.com>\nDate:   Wed Dec 2 14:33:20 2009 +0900\n\n    Merge early part of side branch\n\n    Merge commit 'a1d2374f8f52f4e8a53171601a920b538a6cec23'\n\nI gave my own message because I didn't want git to add the \nstandard message (if I wanted to, I wouldn't have given one, \nor I would have prepared it using git-fmt-merge-msg command).\n\nIs it possible to tell git-merge not to do this, or will it \nbreak compatibility and is a bad idea to change it?\n\nI noticed that this was proposed before:\n\n http://thread.gmane.org/gmane.comp.version-control.git/77965/focus=80059\n\nyou were in favor of changing this behavior, and there was \nno objection from the list.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"129008","messageId":"20091202155446.GU31763@genesis.frugalware.org","threadId":"21824","inReplyTo":"20091202192030.6117@nanako3.lavabit.com","subject":"Re: [BUG?] git-merge appends extra string to user's message?","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T15:54:46Z","receivedAt":"2009-12-02T15:54:46Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Dec 02, 2009 at 07:20:30PM +0900, Nanako Shiraishi <nanako3@lavabit.com> wrote:\n> % git merge -m \"Merge early part of side branch\" `git rev-parse side~2`\n> % git show -s \n> commit 37217141e7519629353738d5e4e677a15096206f\n> Merge: e68e646 a1d2374\n> Author: ???????????? ????????? <nanako3@lavabit.com>\n> Date:   Wed Dec 2 14:33:20 2009 +0900\n> \n>     Merge early part of side branch\n> \n>     Merge commit 'a1d2374f8f52f4e8a53171601a920b538a6cec23'\n\nAt least it's intentional. When I wrote builtin-merge I remember I\nchecked that the script version had this behaviour and that's why I\nimplemented the same way in C.\n"},{"id":"129019","messageId":"7veindi9pe.fsf@alter.siamese.dyndns.org","threadId":"21824","inReplyTo":"20091202192030.6117@nanako3.lavabit.com","subject":"Re: [BUG?] git-merge appends extra string to user's message?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-02T17:09:49Z","receivedAt":"2009-12-02T17:09:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nanako Shiraishi <nanako3@lavabit.com> writes:\n\n> When \"git merge\" is run with a message, it appends an extra message \n> that it would add if it were run without one....\n> \n> I gave my own message because I didn't want git to add the \n> standard message (if I wanted to, I wouldn't have given one, \n> or I would have prepared it using git-fmt-merge-msg command).\n>\n> Is it possible to tell git-merge not to do this, or will it \n> break compatibility and is a bad idea to change it?\n>\n> I noticed that this was proposed before:\n>\n>  http://thread.gmane.org/gmane.comp.version-control.git/77965/focus=80059\n>\n> you were in favor of changing this behavior, and there was no objection\n> from the list.\n\nI am still in favor, and I think we should do this change.  I know Miklos\nsaid it is intentional, but I think he merely means \"The version rewritten\nin C does so intentionally because the version before rewrite did so\", not\nnecessarily because \"the version before rewrite did so intentionally with\ngood reasons.\"\n\nEspecially because we are going to update \"merge\" and eventually drop the\n\"merge <msg> HEAD <commit>...\"  syntax, the first step should be to make\nit equivalent to \"merge -m <msg> <commit...\"\n\nHow does this look?\n\nI stole a major part of your message to the proposed commit log.\n\n-- >8 --\nSubject: [PATCH] merge: do not add standard message when message is given with -m option\n\nEven if the user explicitly gave her own message to \"git merge\", the\ncommand still added its standard merge message.  It resulted in a\nuseless repetition like this:\n\n    % git merge -m \"Merge early part of side branch\" `git rev-parse side~2`\n    % git show -s\n    commit 37217141e7519629353738d5e4e677a15096206f\n    Merge: e68e646 a1d2374\n    Author: しらいし ななこ <nanako3@lavabit.com>\n    Date:   Wed Dec 2 14:33:20 2009 +0900\n\n\tMerge early part of side branch\n\n\tMerge commit 'a1d2374f8f52f4e8a53171601a920b538a6cec23'\n\nThe gave her own message because she didn't want git to add the\nstandard message (if she wanted to, she wouldn't have given one,\nor she would have prepared it using git-fmt-merge-msg command).\n\nNoticed by Nanako Shiraishi\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-merge.c                 |   14 ++++++++------\n t/t7604-merge-custom-message.sh |    7 ++-----\n 2 files changed, 10 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin-merge.c b/builtin-merge.c\nindex 2104577..981fe4b 100644\n--- a/builtin-merge.c\n+++ b/builtin-merge.c\n@@ -71,7 +71,7 @@ static int option_parse_message(const struct option *opt,\n \tif (unset)\n \t\tstrbuf_setlen(buf, 0);\n \telse if (arg) {\n-\t\tstrbuf_addf(buf, \"%s\\n\\n\", arg);\n+\t\tstrbuf_addf(buf, \"%s%s\", buf->len ? \"\\n\\n\" : \"\", arg);\n \t\thave_message = 1;\n \t} else\n \t\treturn error(\"switch `m' requires a value\");\n@@ -943,11 +943,13 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t * codepath so we discard the error in this\n \t\t * loop.\n \t\t */\n-\t\tfor (i = 0; i < argc; i++)\n-\t\t\tmerge_name(argv[i], &msg);\n-\t\tfmt_merge_msg(option_log, &msg, &merge_msg);\n-\t\tif (merge_msg.len)\n-\t\t\tstrbuf_setlen(&merge_msg, merge_msg.len-1);\n+\t\tif (!have_message) {\n+\t\t\tfor (i = 0; i < argc; i++)\n+\t\t\t\tmerge_name(argv[i], &msg);\n+\t\t\tfmt_merge_msg(option_log, &msg, &merge_msg);\n+\t\t\tif (merge_msg.len)\n+\t\t\t\tstrbuf_setlen(&merge_msg, merge_msg.len-1);\n+\t\t}\n \t}\n \n \tif (head_invalid || !argc)\ndiff --git a/t/t7604-merge-custom-message.sh b/t/t7604-merge-custom-message.sh\nindex de977c5..269cfdf 100755\n--- a/t/t7604-merge-custom-message.sh\n+++ b/t/t7604-merge-custom-message.sh\n@@ -22,15 +22,12 @@ test_expect_success 'setup' '\n \tgit tag c2\n '\n \n-cat >expected <<\\EOF\n-custom message\n \n-Merge commit 'c2'\n-EOF\n test_expect_success 'merge c2 with a custom message' '\n \tgit reset --hard c1 &&\n+\techo >expected \"custom message\" &&\n \tgit merge -m \"custom message\" c2 &&\n-\tgit cat-file commit HEAD | sed -e \"1,/^$/d\" > actual &&\n+\tgit cat-file commit HEAD | sed -e \"1,/^$/d\" >actual &&\n \ttest_cmp expected actual\n '\n \n-- \n1.6.6.rc0\n"},{"id":"129022","messageId":"20091202171302.GZ31763@genesis.frugalware.org","threadId":"21824","inReplyTo":"7veindi9pe.fsf@alter.siamese.dyndns.org","subject":"Re: [BUG?] git-merge appends extra string to user's message?","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T17:13:02Z","receivedAt":"2009-12-02T17:13:02Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Dec 02, 2009 at 09:09:49AM -0800, Junio C Hamano <gitster@pobox.com> wrote:\n> I am still in favor, and I think we should do this change.  I know Miklos\n> said it is intentional, but I think he merely means \"The version rewritten\n> in C does so intentionally because the version before rewrite did so\", not\n> necessarily because \"the version before rewrite did so intentionally with\n> good reasons.\"\n\nExactly.\n\n> How does this look?\n\nLooks fine.\n"}]}