builtin-merge.c: Fix option parsing
authorMichele Ballabio <barra_cuda@katamail.com>
Sun, 20 Jul 2008 12:34:47 +0000 (14:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 20 Jul 2008 20:37:26 +0000 (13:37 -0700)
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>
Acked-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-merge.c
t/t7600-merge.sh
index 06b9970306396ca8ef2b64d95a411280796f4017..e97c79e60cdb8227ad682a3927ae955005cbe1f3 100644 (file)
@@ -66,10 +66,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;
 }
 
index 26cf8dc7c15ce397d7c36b2dd39a9d38db9856d7..5eeb6c2b2708d582a6e86cd2e06e2b00b7b7b391 100755 (executable)
@@ -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 &&