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>
This commit is contained in:

committed by
Junio C Hamano

parent
640d0401be
commit
43722c4d9e
@ -859,7 +859,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
|
|||||||
else if (argc == 1)
|
else if (argc == 1)
|
||||||
branch_name = argv[0];
|
branch_name = argv[0];
|
||||||
else
|
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);
|
strbuf_addf(&branch_ref, "refs/heads/%s", branch_name);
|
||||||
if (!ref_exists(branch_ref.buf)) {
|
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)
|
else if (argc == 2)
|
||||||
rename_branch(argv[0], argv[1], rename > 1);
|
rename_branch(argv[0], argv[1], rename > 1);
|
||||||
else
|
else
|
||||||
usage_with_options(builtin_branch_usage, options);
|
die(_("too many branches for a rename operation"));
|
||||||
} else if (new_upstream) {
|
} else if (new_upstream) {
|
||||||
struct branch *branch = branch_get(argv[0]);
|
struct branch *branch = branch_get(argv[0]);
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ test_expect_success \
|
|||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'git branch -m dumps usage' \
|
'git branch -m dumps usage' \
|
||||||
'test_expect_code 129 git branch -m 2>err &&
|
'test_expect_code 128 git branch -m 2>err &&
|
||||||
test_i18ngrep "[Uu]sage: git branch" err'
|
test_i18ngrep "too many branches for a rename operation" err'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'git branch -m m m/m should work' \
|
'git branch -m m m/m should work' \
|
||||||
|
Reference in New Issue
Block a user