branch: give a more helpful message on redundant arguments
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Mon, 28 Jan 2013 01:18:15 +0000 (08:18 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Jan 2013 17:00:41 +0000 (09:00 -0800)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c
t/t3200-branch.sh

index 50fcaccab0651a1ad3afb8d02691317756e46d1d..531a21e831f84bf9484548507e8428d662ecaa91 100644 (file)
@@ -859,7 +859,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                else if (argc == 1)
                        branch_name = argv[0];
                else
-                       usage_with_options(builtin_branch_usage, options);
+                       die(_("cannot edit description of more than one branch"));
 
                strbuf_addf(&branch_ref, "refs/heads/%s", branch_name);
                if (!ref_exists(branch_ref.buf)) {
@@ -881,7 +881,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                else if (argc == 2)
                        rename_branch(argv[0], argv[1], rename > 1);
                else
-                       usage_with_options(builtin_branch_usage, options);
+                       die(_("too many branches for a rename operation"));
        } else if (new_upstream) {
                struct branch *branch = branch_get(argv[0]);
 
index 80e6be39d7b76d8e5daa6cad24a22a80a42e8eff..f3e0e4a38c3188760df8cb5bd4c096e2209fed9f 100755 (executable)
@@ -73,8 +73,8 @@ test_expect_success \
 
 test_expect_success \
     'git branch -m dumps usage' \
-       'test_expect_code 129 git branch -m 2>err &&
-       test_i18ngrep "[Uu]sage: git branch" err'
+       'test_expect_code 128 git branch -m 2>err &&
+       test_i18ngrep "too many branches for a rename operation" err'
 
 test_expect_success \
     'git branch -m m m/m should work' \