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

[PATCH] builtin-merge.c: Fix option parsing

From
Michele Ballabio <barra_cuda@katamail.com>
Date
Jul 20, 2008, 12:34 UTC
Message-ID
<200807201434.47545.barra_cuda@katamail.com>

Now "git merge -m" needs a message, and errors out with the usage text if none is given. This way, t7600-merge.sh is fixed.

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
---
 builtin-merge.c  |    5 +++--
 t/t7600-merge.sh |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/builtin-merge.c b/builtin-merge.c
index 129b4e6..84a541d 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -68,10 +68,11 @@ static int option_parse_message(const struct option *opt,
 
 	if (unset)
 		strbuf_setlen(buf, 0);
-	else {
+	else if (arg) {
 		strbuf_addf(buf, "%s\n\n", arg);
 		have_message = 1;
-	}
+	} else
+		return error("switch `m' requires a value");
 	return 0;
 }
 
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 26cf8dc..5eeb6c2 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -221,7 +221,7 @@ test_expect_success 'setup' '
 
 test_debug 'gitk --all'
 
-test_expect_failure 'test option parsing' '
+test_expect_success 'test option parsing' '
 	test_must_fail git merge -$ c1 &&
 	test_must_fail git merge --no-such c1 &&
 	test_must_fail git merge -s foobar c1 &&
-- 
1.5.6.3
Next: Miklos Vajna
Message 1 of 2 in “builtin-merge.c: Fix option parsing”
  1. builtin-merge.c: Fix option parsingMichele Ballabio, Jul 20, 2008
  2. Miklos VajnaJul 20, 2008

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.