builtin/branch.c: remove useless branch_get
commit8d2008196b4e6100cf90e8392106e82f46cc1a51
authorTao Qingyun <taoqy@ls-a.me>
Tue, 16 Oct 2018 14:54:28 +0000 (16 22:54 +0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Oct 2018 01:57:31 +0000 (18 10:57 +0900)
treee581eff863f2724385a16193bcf2feff843b2b0f
parentcae598d9980661a978e2df4fb338518f7bf09572
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 <taoqy@ls-a.me>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c