Skip to content

Commit 948cf4f

Browse files
committed
Merge branch 'rt/commentchar-fmt-merge-msg'
The new core.commentchar configuration was not applied to a few places. * rt/commentchar-fmt-merge-msg: fmt-merge-msg: use core.commentchar in tag signatures completely fmt-merge-msg: respect core.commentchar in people credits
2 parents e1a3f17 + 89c3bbd commit 948cf4f

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

builtin/fmt-merge-msg.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,10 @@ static void credit_people(struct strbuf *out,
287287
const char *me;
288288

289289
if (kind == 'a') {
290-
label = "\n# By ";
290+
label = "By";
291291
me = git_author_info(IDENT_NO_DATE);
292292
} else {
293-
label = "\n# Via ";
293+
label = "Via";
294294
me = git_committer_info(IDENT_NO_DATE);
295295
}
296296

@@ -300,7 +300,7 @@ static void credit_people(struct strbuf *out,
300300
(me = skip_prefix(me, them->items->string)) != NULL &&
301301
skip_prefix(me, " <")))
302302
return;
303-
strbuf_addstr(out, label);
303+
strbuf_addf(out, "\n%c %s ", comment_line_char, label);
304304
add_people_count(out, them);
305305
}
306306

@@ -503,14 +503,18 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
503503
} else {
504504
if (tag_number == 2) {
505505
struct strbuf tagline = STRBUF_INIT;
506-
strbuf_addf(&tagline, "\n# %s\n",
507-
origins.items[first_tag].string);
506+
strbuf_addch(&tagline, '\n');
507+
strbuf_add_commented_lines(&tagline,
508+
origins.items[first_tag].string,
509+
strlen(origins.items[first_tag].string));
508510
strbuf_insert(&tagbuf, 0, tagline.buf,
509511
tagline.len);
510512
strbuf_release(&tagline);
511513
}
512-
strbuf_addf(&tagbuf, "\n# %s\n",
513-
origins.items[i].string);
514+
strbuf_addch(&tagbuf, '\n');
515+
strbuf_add_commented_lines(&tagbuf,
516+
origins.items[i].string,
517+
strlen(origins.items[i].string));
514518
fmt_tag_signature(&tagbuf, &sig, buf, len);
515519
}
516520
strbuf_release(&sig);

t/t6200-fmt-merge-msg.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,24 @@ test_expect_success 'merge.log=5 shows all 5 commits' '
175175
test_cmp expected actual
176176
'
177177

178+
test_expect_success '--log=5 with custom comment character' '
179+
cat >expected <<-EOF &&
180+
Merge branch ${apos}left${apos}
181+
182+
/ By Another Author (3) and A U Thor (2)
183+
/ Via Another Committer
184+
* left:
185+
Left #5
186+
Left #4
187+
Left #3
188+
Common #2
189+
Common #1
190+
EOF
191+
192+
git -c core.commentchar="/" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
193+
test_cmp expected actual
194+
'
195+
178196
test_expect_success 'merge.log=0 disables shortlog' '
179197
echo "Merge branch ${apos}left${apos}" >expected
180198
git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&

0 commit comments

Comments
 (0)