branch: give a more helpful message on redundant arguments

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jan 28, 2013 at 08:18 UTC 43722c4d9e04b3749372b13598b32cdceb1f1252
2 files changed +4 -4
builtin/branch.c
+2 -2
@@ -859,7 +859,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
859 else if (argc == 1)
860 branch_name = argv[0];
861 else
862 - usage_with_options(builtin_branch_usage, options);
862 + die(_("cannot edit description of more than one branch"));
863
864 strbuf_addf(&branch_ref, "refs/heads/%s", branch_name);
865 if (!ref_exists(branch_ref.buf)) {
@@ -881,7 +881,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
881 else if (argc == 2)
882 rename_branch(argv[0], argv[1], rename > 1);
883 else
884 - usage_with_options(builtin_branch_usage, options);
884 + die(_("too many branches for a rename operation"));
885 } else if (new_upstream) {
886 struct branch *branch = branch_get(argv[0]);
887
t/t3200-branch.sh
+2 -2
@@ -73,8 +73,8 @@ test_expect_success \
73
74 test_expect_success \
75 'git branch -m dumps usage' \
76 - 'test_expect_code 129 git branch -m 2>err &&
77 - test_i18ngrep "[Uu]sage: git branch" err'
76 + 'test_expect_code 128 git branch -m 2>err &&
77 + test_i18ngrep "too many branches for a rename operation" err'
78
79 test_expect_success \
80 'git branch -m m m/m should work' \