builtin/branch.c: remove useless branch_get
diff mbox series

Message ID 20181015140839.4925-1-taoqy@ls-a.me
State New
Headers show
Series
  • builtin/branch.c: remove useless branch_get
Related show

Commit Message

Tao Qingyun Oct. 15, 2018, 2:08 p.m. UTC
Signed-off-by: Tao Qingyun <taoqy@ls-a.me>
---
 builtin/branch.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Jeff King Oct. 15, 2018, 5:17 p.m. UTC | #1
On Mon, Oct 15, 2018 at 10:08:39PM +0800, Tao Qingyun wrote:

> Signed-off-by: Tao Qingyun <taoqy@ls-a.me>

The commit message should describe the "why" here. I gave some reasoning
nearby in:

  https://public-inbox.org/git/20181015171417.GA1301@sigill.intra.peff.net/

From your initial message, it sounds like this might also be fixing a
bug ("confusing that getting a branch before it has created"). Can you
describe that (and ideally show the fix with a test)?

> 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]);
> -

From what I can tell, the patch itself _is_ an improvement. I just think
we need to explain why for the record.

-Peff

Patch
diff mbox series

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"));