Skip to content

Commit 9927ebe

Browse files
ralfthgitster
authored andcommitted
fmt-merge-msg: respect core.commentchar in people credits
Commit eff80a9 (Allow custom "comment char") introduced a custom comment character for commit messages but forgot to use it in people credits which can be a part of a commit message. With this commit, the custom comment character is also used in people credits. Signed-off-by: Ralf Thielow <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 239222f commit 9927ebe

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

builtin/fmt-merge-msg.c

Lines changed: 3 additions & 3 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

t/t6200-fmt-merge-msg.sh

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

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

0 commit comments

Comments
 (0)