提交 8d200819 编写于 作者: T Tao Qingyun 提交者: Junio C Hamano

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: NTao Qingyun <taoqy@ls-a.me>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 cae598d9
......@@ -828,11 +828,6 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
git_config_set_multivar(buf.buf, NULL, NULL, 1);
strbuf_release(&buf);
} else if (argc > 0 && argc <= 2) {
struct branch *branch = branch_get(argv[0]);
if (!branch)
die(_("no such branch '%s'"), argv[0]);
if (filter.kind != FILTER_REFS_BRANCHES)
die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册