[PATCH 1/7] fmt-merge-msg: be quiet if nothing to merge
From: Stephen Boyd <hidden>
Date: 2016-06-15 22:48:29
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted> --- builtin/fmt-merge-msg.c | 3 +++ t/t6200-fmt-merge-msg.sh | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 9d52400..9bb2625 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c@@ -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];
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 42f6fff..ade209a 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh@@ -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 &&
@@ -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
--
1.7.0.3.254.g4503b