Skip to content

Commit 8d20081

Browse files
taoqygitster
authored andcommitted
builtin/branch.c: remove useless branch_get
branch_get sometimes returns current_branch, which can be NULL (e.g., if you're on a detached HEAD). Try: $ git branch HEAD fatal: no such branch 'HEAD' $ git branch '' fatal: no such branch '' However, it seems weird that we'd check those cases here (and provide such lousy messages). And indeed, dropping that and letting us eventually hit create_branch() gives a much better message: $ git branch HEAD fatal: 'HEAD' is not a valid branch name. $ git branch '' fatal: '' is not a valid branch name. Signed-off-by: Tao Qingyun <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cae598d commit 8d20081

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

builtin/branch.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -828,11 +828,6 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
828828
git_config_set_multivar(buf.buf, NULL, NULL, 1);
829829
strbuf_release(&buf);
830830
} else if (argc > 0 && argc <= 2) {
831-
struct branch *branch = branch_get(argv[0]);
832-
833-
if (!branch)
834-
die(_("no such branch '%s'"), argv[0]);
835-
836831
if (filter.kind != FILTER_REFS_BRANCHES)
837832
die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
838833

0 commit comments

Comments
 (0)