git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/7] fmt-merge-msg: be quiet if nothing to merge

From
Stephen Boyd <bebarino@gmail.com>
Date
Mar 24, 2010, 07:15 UTC
Message-ID
<1269414964-9518-2-git-send-email-bebarino@gmail.com>
In-Reply-To
<1269414964-9518-1-git-send-email-bebarino@gmail.com>

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>
---
 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
Previous: Stephen BoydNext: Junio C Hamano
Message 2 of 17 in “fmt-merge-msg improvements”
  1. 0/7 fmt-merge-msg improvementsStephen Boyd, Mar 24, 2010
  2. 1/7 fmt-merge-msg: be quiet if nothing to mergeStephen Boyd, Mar 24, 2010
  3. Junio C HamanoMar 25, 2010
  4. Stephen BoydMar 25, 2010
  5. 2/7 t6200: modernize with test_tickStephen Boyd, Mar 24, 2010
  6. 3/7 t6200: test fmt-merge-msg moreStephen Boyd, Mar 24, 2010
  7. 4/7 fmt-merge-msg: use pretty.c routinesStephen Boyd, Mar 24, 2010
  8. 5/7 string-list: add unsorted_string_list_lookup()Stephen Boyd, Mar 24, 2010
  9. 6/7 fmt-merge-msg: remove custom string_list implementationStephen Boyd, Mar 24, 2010
  10. Junio C HamanoMar 30, 2010
  11. Stephen BoydApr 1, 2010
  12. 8/7 Make string_list_append() consistent with everything elseStephen Boyd, Apr 1, 2010
  13. Julian PhillipsApr 1, 2010
  14. 7/7 fmt-merge-msg: hide summary optionStephen Boyd, Mar 24, 2010
  15. Junio C HamanoMar 25, 2010
  16. Stephen BoydMar 25, 2010
  17. Junio C HamanoMar 26, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.