@matheusbsbs / matheus-bagliano / commits / 419fe5bc86
Fork 0

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 <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Mar 24, 2010 at 00:15 UTC 419fe5bc861517c789c8f028519e085fd8d1992f
2 files changed +22
builtin/fmt-merge-msg.c
+3
@@ -281,6 +281,9 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
281 die ("Error in line %d: %.*s", i, len, p);
282 }
283
284 + if (!srcs.nr)
285 + return 0;
286 +
287 strbuf_addstr(out, "Merge ");
288 for (i = 0; i < srcs.nr; i++) {
289 struct src_data *src_data = srcs.payload[i];
t/t6200-fmt-merge-msg.sh
+19
@@ -21,6 +21,8 @@ test_expect_success setup '
21 setdate &&
22 git commit -m "Initial" &&
23
24 + git clone . remote &&
25 +
26 echo uno >one &&
27 echo dos >two &&
28 git add two &&
@@ -240,4 +242,21 @@ test_expect_success 'merge-msg -F in subdirectory' '
242 test_cmp expected actual
243 '
244
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 +
262 test_done