Skip to content

Commit

Permalink
fmt-merge-msg: be quiet if nothing to merge
Browse files Browse the repository at this point in the history
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 <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Stephen Boyd authored and Junio C Hamano committed Mar 25, 2010
1 parent 5e4f614 commit 419fe5b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/fmt-merge-msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
die ("Error in line %d: %.*s", i, len, p);
}

if (!srcs.nr)
return 0;

strbuf_addstr(out, "Merge ");
for (i = 0; i < srcs.nr; i++) {
struct src_data *src_data = srcs.payload[i];
Expand Down
19 changes: 19 additions & 0 deletions t/t6200-fmt-merge-msg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ test_expect_success setup '
setdate &&
git commit -m "Initial" &&
git clone . remote &&
echo uno >one &&
echo dos >two &&
git add two &&
Expand Down Expand Up @@ -240,4 +242,21 @@ test_expect_success 'merge-msg -F in subdirectory' '
test_cmp expected actual
'

test_expect_success 'merge-msg with nothing to merge' '
git config --unset-all merge.log
git config --unset-all merge.summary
git config merge.summary yes &&
(
cd remote &&
git checkout -b unrelated &&
setdate &&
git fetch origin &&
git fmt-merge-msg <.git/FETCH_HEAD >../actual
) &&
test_cmp /dev/null actual
'

test_done

0 comments on commit 419fe5b

Please sign in to comment.