{"thread":{"id":"32486","subject":"[PATCH] merge --no-edit: do not add comments meant for \"--edit\" mode","startedAt":"2012-12-31T18:33:12Z","lastAt":"2012-12-31T18:33:12Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"205702","messageId":"7vehi6dqc7.fsf@alter.siamese.dyndns.org","threadId":"32486","inReplyTo":null,"subject":"[PATCH] merge --no-edit: do not add comments meant for \"--edit\" mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-31T18:33:12Z","receivedAt":"2012-12-31T18:33:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The credit lines \"By\" and \"Via\" to credit authors and committers for\ntheir contributions on the side branch are meant as a hint to the\nintegrator to decide whom to mention in the log message text.  After\nthe integrator saves the message in the editor, they are meant to go\naway and that is why they are commented out.\n\nWhen a merge is recorded without editing the generated message,\nhowever, its contents do not go through the normal stripspace()\nand these lines are left in the merge.\n\nStop producing them when we know the merge is going to be recorded\nwithout editing, i.e. when --no-edit is given.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin.h               |  3 ++-\n builtin/fmt-merge-msg.c | 21 ++++++++++++++-------\n builtin/merge.c         |  1 +\n 3 files changed, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin.h b/builtin.h\nindex dffb34e..3ad8d19 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -16,7 +16,8 @@ extern const char git_more_info_string[];\n extern void prune_packed_objects(int);\n \n struct fmt_merge_msg_opts {\n-\tunsigned add_title:1;\n+\tunsigned add_title:1,\n+\t\tcredit_people:1;\n \tint shortlog_len;\n };\n \ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 2c4d435..dd1f363 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -232,8 +232,9 @@ static void record_person(int which, struct string_list *people,\n {\n \tchar *name_buf, *name, *name_end;\n \tstruct string_list_item *elem;\n-\tconst char *field = (which == 'a') ? \"\\nauthor \" : \"\\ncommitter \";\n+\tconst char *field;\n \n+\tfield = (which == 'a') ? \"\\nauthor \" : \"\\ncommitter \";\n \tname = strstr(commit->buffer, field);\n \tif (!name)\n \t\treturn;\n@@ -323,7 +324,8 @@ static void add_people_info(struct strbuf *out,\n static void shortlog(const char *name,\n \t\t     struct origin_data *origin_data,\n \t\t     struct commit *head,\n-\t\t     struct rev_info *rev, int limit,\n+\t\t     struct rev_info *rev,\n+\t\t     struct fmt_merge_msg_opts *opts,\n \t\t     struct strbuf *out)\n {\n \tint i, count = 0;\n@@ -335,6 +337,7 @@ static void shortlog(const char *name,\n \tint flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED;\n \tstruct strbuf sb = STRBUF_INIT;\n \tconst unsigned char *sha1 = origin_data->sha1;\n+\tint limit = opts->shortlog_len;\n \n \tbranch = deref_tag(parse_object(sha1), sha1_to_hex(sha1), 40);\n \tif (!branch || branch->type != OBJ_COMMIT)\n@@ -351,13 +354,15 @@ static void shortlog(const char *name,\n \n \t\tif (commit->parents && commit->parents->next) {\n \t\t\t/* do not list a merge but count committer */\n-\t\t\trecord_person('c', &committers, commit);\n+\t\t\tif (opts->credit_people)\n+\t\t\t\trecord_person('c', &committers, commit);\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!count)\n+\t\tif (!count && opts->credit_people)\n \t\t\t/* the 'tip' committer */\n \t\t\trecord_person('c', &committers, commit);\n-\t\trecord_person('a', &authors, commit);\n+\t\tif (opts->credit_people)\n+\t\t\trecord_person('a', &authors, commit);\n \t\tcount++;\n \t\tif (subjects.nr > limit)\n \t\t\tcontinue;\n@@ -372,7 +377,8 @@ static void shortlog(const char *name,\n \t\t\tstring_list_append(&subjects, strbuf_detach(&sb, NULL));\n \t}\n \n-\tadd_people_info(out, &authors, &committers);\n+\tif (opts->credit_people)\n+\t\tadd_people_info(out, &authors, &committers);\n \tif (count > limit)\n \t\tstrbuf_addf(out, \"\\n* %s: (%d commits)\\n\", name, count);\n \telse\n@@ -635,7 +641,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,\n \t\tfor (i = 0; i < origins.nr; i++)\n \t\t\tshortlog(origins.items[i].string,\n \t\t\t\t origins.items[i].util,\n-\t\t\t\t head, &rev, opts->shortlog_len, out);\n+\t\t\t\t head, &rev, opts, out);\n \t}\n \n \tstrbuf_complete_line(out);\n@@ -690,6 +696,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)\n \n \tmemset(&opts, 0, sizeof(opts));\n \topts.add_title = !message;\n+\topts.credit_people = 1;\n \topts.shortlog_len = shortlog_len;\n \n \tret = fmt_merge_msg(&input, &output, &opts);\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex e81fde6..c5d3551 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1324,6 +1324,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t\tmemset(&opts, 0, sizeof(opts));\n \t\t\topts.add_title = !have_message;\n \t\t\topts.shortlog_len = shortlog_len;\n+\t\t\topts.credit_people = (0 < option_edit);\n \n \t\t\tfmt_merge_msg(&merge_names, &merge_msg, &opts);\n \t\t\tif (merge_msg.len)\n-- \n1.8.1.rc3.236.g505e3af\n"}]}