merge: ensure '--abort' option takes no arguments
authorChris Packham <judge.packham@gmail.com>
Wed, 14 Dec 2016 08:37:57 +0000 (21:37 +1300)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Dec 2016 18:02:04 +0000 (10:02 -0800)
Like '--continue', the '--abort' option doesn't make any sense with
other options or arguments to 'git merge' so ensure that none are
present.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge.c
t/t7600-merge.sh
index 836ec281b497e7b432ad8024d93f27ad6862fb70..668aaffb849d5c9838157f6906b5649f72d9d67b 100644 (file)
@@ -1163,6 +1163,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                int nargc = 2;
                const char *nargv[] = {"reset", "--merge", NULL};
 
+               if (orig_argc != 2)
+                       usage_msg_opt("--abort expects no arguments",
+                             builtin_merge_usage, builtin_merge_options);
+
                if (!file_exists(git_path_merge_head()))
                        die(_("There is no merge to abort (MERGE_HEAD missing)."));
 
index 682139c4ea30c705db65823b80166380f5bf55b2..2ebda509ac337f99c7ab5651734a5b20d4a0b6f4 100755 (executable)
@@ -154,6 +154,8 @@ test_expect_success 'test option parsing' '
        test_must_fail git merge -s foobar c1 &&
        test_must_fail git merge -s=foobar c1 &&
        test_must_fail git merge -m &&
+       test_must_fail git merge --abort foobar &&
+       test_must_fail git merge --abort --quiet &&
        test_must_fail git merge --continue foobar &&
        test_must_fail git merge --continue --quiet &&
        test_must_fail git merge