Skip to contentSkip to conversation

builtin-merge.c: Fix option parsing

PATCH In review Michele Ballabio 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 builtin-merge.c: Fix option parsing

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.

---
 builtin-merge.c  |    5 +++--
 t/t7600-merge.sh |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
builtin-merge.c +3 -2
index 129b4e6..84a541d 100644
@@ -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;
 }
 
t/t7600-merge.sh +1 -1
index 26cf8dc..5eeb6c2 100755
@@ -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 &&
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 3 lines · Michele Ballabio

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.

Thanks, I was about to fix this, but you were faster. ;-)