Skip to content

Commit 8054b9a

Browse files
committed
Merge branch 'jm/branch-rename-nothing-error'
"git branch -m" without any argument noticed an error, but with an incorrect error message. * jm/branch-rename-nothing-error: branch: give better message when no names specified for rename
2 parents ed23f31 + d1520c4 commit 8054b9a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

builtin/branch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
904904
if (edit_branch_description(branch_name))
905905
return 1;
906906
} else if (rename) {
907-
if (argc == 1)
907+
if (!argc)
908+
die(_("branch name required"));
909+
else if (argc == 1)
908910
rename_branch(head, argv[0], rename > 1);
909911
else if (argc == 2)
910912
rename_branch(argv[0], argv[1], rename > 1);

t/t3200-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test_expect_success 'git branch l should work after branch l/m has been deleted'
7575

7676
test_expect_success 'git branch -m dumps usage' '
7777
test_expect_code 128 git branch -m 2>err &&
78-
test_i18ngrep "too many branches for a rename operation" err
78+
test_i18ngrep "branch name required" err
7979
'
8080

8181
test_expect_success 'git branch -m m m/m should work' '

0 commit comments

Comments
 (0)