merge --no-edit: do not credit people involved in the side branch
The credit lines "By" and "Via" to credit authors and committers for their contributions on the side branch are meant as a hint to the integrator to decide whom to mention in the log message text. After the integrator saves the message in the editor, they are meant to go away and that is why they are commented out. When a merge is recorded without editing the generated message, however, its contents do not go through the normal stripspace() and these lines are left in the merge. Stop producing them when we know the merge is going to be recorded without editing, i.e. when --no-edit is given. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Dec 28, 2012 at 15:29 UTC
9bcbb1c218d075d8b180cfef4c9089f868151e7e
3 files changed
+17
-8
builtin.h
+2
-1
@@ -16,7 +16,8 @@ extern const char git_more_info_string[];
16
extern void prune_packed_objects(int);
17
18
struct fmt_merge_msg_opts {
19
- unsigned add_title:1;
19
+ unsigned add_title:1,
20
+ credit_people:1;
21
int shortlog_len;
22
};
23
builtin/fmt-merge-msg.c
+14
-7
@@ -232,8 +232,9 @@ static void record_person(int which, struct string_list *people,
232
{
233
char *name_buf, *name, *name_end;
234
struct string_list_item *elem;
235
- const char *field = (which == 'a') ? "\nauthor " : "\ncommitter ";
235
+ const char *field;
236
237
+ field = (which == 'a') ? "\nauthor " : "\ncommitter ";
238
name = strstr(commit->buffer, field);
239
if (!name)
240
return;
@@ -323,7 +324,8 @@ static void add_people_info(struct strbuf *out,
324
static void shortlog(const char *name,
325
struct origin_data *origin_data,
326
struct commit *head,
326
- struct rev_info *rev, int limit,
327
+ struct rev_info *rev,
328
+ struct fmt_merge_msg_opts *opts,
329
struct strbuf *out)
330
{
331
int i, count = 0;
@@ -335,6 +337,7 @@ static void shortlog(const char *name,
337
int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED;
338
struct strbuf sb = STRBUF_INIT;
339
const unsigned char *sha1 = origin_data->sha1;
340
+ int limit = opts->shortlog_len;
341
342
branch = deref_tag(parse_object(sha1), sha1_to_hex(sha1), 40);
343
if (!branch || branch->type != OBJ_COMMIT)
@@ -351,13 +354,15 @@ static void shortlog(const char *name,
354
355
if (commit->parents && commit->parents->next) {
356
/* do not list a merge but count committer */
354
- record_person('c', &committers, commit);
357
+ if (opts->credit_people)
358
+ record_person('c', &committers, commit);
359
continue;
360
}
357
- if (!count)
361
+ if (!count && opts->credit_people)
362
/* the 'tip' committer */
363
record_person('c', &committers, commit);
360
- record_person('a', &authors, commit);
364
+ if (opts->credit_people)
365
+ record_person('a', &authors, commit);
366
count++;
367
if (subjects.nr > limit)
368
continue;
@@ -372,7 +377,8 @@ static void shortlog(const char *name,
377
string_list_append(&subjects, strbuf_detach(&sb, NULL));
378
}
379
375
- add_people_info(out, &authors, &committers);
380
+ if (opts->credit_people)
381
+ add_people_info(out, &authors, &committers);
382
if (count > limit)
383
strbuf_addf(out, "\n* %s: (%d commits)\n", name, count);
384
else
@@ -635,7 +641,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
641
for (i = 0; i < origins.nr; i++)
642
shortlog(origins.items[i].string,
643
origins.items[i].util,
638
- head, &rev, opts->shortlog_len, out);
644
+ head, &rev, opts, out);
645
}
646
647
strbuf_complete_line(out);
@@ -690,6 +696,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
696
697
memset(&opts, 0, sizeof(opts));
698
opts.add_title = !message;
699
+ opts.credit_people = 1;
700
opts.shortlog_len = shortlog_len;
701
702
ret = fmt_merge_msg(&input, &output, &opts);
builtin/merge.c
+1
@@ -1324,6 +1324,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1324
memset(&opts, 0, sizeof(opts));
1325
opts.add_title = !have_message;
1326
opts.shortlog_len = shortlog_len;
1327
+ opts.credit_people = (0 < option_edit);
1328
1329
fmt_merge_msg(&merge_names, &merge_msg, &opts);
1330
if (merge_msg.len)