From patchwork Tue Oct 16 14:54:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Qingyun X-Patchwork-Id: 10643757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70D9A14E2 for ; Tue, 16 Oct 2018 15:02:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D83529EB9 for ; Tue, 16 Oct 2018 15:02:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5152B29F0B; Tue, 16 Oct 2018 15:02:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.6 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_SBL_CSS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3A2129F2A for ; Tue, 16 Oct 2018 15:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbeJPWxE (ORCPT ); Tue, 16 Oct 2018 18:53:04 -0400 Received: from smtpbg298.qq.com ([184.105.67.102]:49316 "EHLO smtpbg298.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbeJPWxE (ORCPT ); Tue, 16 Oct 2018 18:53:04 -0400 X-Greylist: delayed 442 seconds by postgrey-1.27 at vger.kernel.org; Tue, 16 Oct 2018 18:53:03 EDT X-QQ-mid: Xesmtp4t1539701683tpj4v6ee8 Received: from localhost.localdomain (unknown [180.165.118.30]) by esmtp4.qq.com (ESMTP) with id ; Tue, 16 Oct 2018 22:54:42 +0800 (CST) X-QQ-SSF: B1000000000000F0F5100000000000Z X-QQ-FEAT: JOVh5Yj1n8YiGvnJRN/Dx0GVy00d8+ISLbZaHRmkIYDJZoN2c6CH8paaki5vr LOHiVMsaFF+Ek26xgikZLiGX6b+unENZn94i4+JW/4rY4uRwWmDXBUS+jZ3eizuyHOEu0/x HZkvAazN2I0BgmazhBCjQc5+QNlXFRYy9TyPKKoWXUAa40FxcQSYlgjDWMgYUayReRIsl0m f9O30MTtiLkm6EI+HeXKBKKcoVL+IRa7YlELMSbSYK9uRhrz9qwqijt5SsEbAXMJ7KqGlqK SR6B2TZRtLuGnHaUh7/PZftXrQ9FyDlLsIgw== X-QQ-GoodBg: 0 From: Tao Qingyun To: peff@peff.net Cc: avarab@gmail.com, git@vger.kernel.org, gitster@pobox.com, Tao Qingyun Subject: [PATCH v2] builtin/branch.c: remove useless branch_get Date: Tue, 16 Oct 2018 22:54:28 +0800 Message-Id: <20181016145428.2901-1-taoqy@ls-a.me> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181015171707.GB1301@sigill.intra.peff.net> References: <20181015171707.GB1301@sigill.intra.peff.net> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 X-QQ-FName: 46F629798DA84E4DAEF77E5849CC8D75 X-QQ-LocalIP: 10.198.131.167 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- builtin/branch.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index c396c41533..2367703034 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -809,11 +809,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"));