Skip to content

Commit 419fe5b

Browse files
bebarinogitster
authored andcommitted
fmt-merge-msg: be quiet if nothing to merge
When FETCH_HEAD contains only 'not-for-merge' entries fmt-merge-msg still outputs "Merge" (and if the branch isn't master " into <branch>"). In this case fmt-merge-msg is outputting junk and should really just be quiet. Fix it. Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5e4f614 commit 419fe5b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

builtin/fmt-merge-msg.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
281281
die ("Error in line %d: %.*s", i, len, p);
282282
}
283283

284+
if (!srcs.nr)
285+
return 0;
286+
284287
strbuf_addstr(out, "Merge ");
285288
for (i = 0; i < srcs.nr; i++) {
286289
struct src_data *src_data = srcs.payload[i];

t/t6200-fmt-merge-msg.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ test_expect_success setup '
2121
setdate &&
2222
git commit -m "Initial" &&
2323
24+
git clone . remote &&
25+
2426
echo uno >one &&
2527
echo dos >two &&
2628
git add two &&
@@ -240,4 +242,21 @@ test_expect_success 'merge-msg -F in subdirectory' '
240242
test_cmp expected actual
241243
'
242244

245+
test_expect_success 'merge-msg with nothing to merge' '
246+
247+
git config --unset-all merge.log
248+
git config --unset-all merge.summary
249+
git config merge.summary yes &&
250+
251+
(
252+
cd remote &&
253+
git checkout -b unrelated &&
254+
setdate &&
255+
git fetch origin &&
256+
git fmt-merge-msg <.git/FETCH_HEAD >../actual
257+
) &&
258+
259+
test_cmp /dev/null actual
260+
'
261+
243262
test_done

0 commit comments

Comments
 (0)