From 640d0401be5f29db8c9e914d8a19dbc9b950448d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 28 Jan 2013 08:18:14 +0700 Subject: branch: reject -D/-d without branch name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/branch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'builtin/branch.c') diff --git a/builtin/branch.c b/builtin/branch.c index 873f624d1..50fcaccab 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -837,9 +837,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix) colopts = 0; } - if (delete) + if (delete) { + if (!argc) + die(_("branch name required")); return delete_branches(argc, argv, delete > 1, kinds, quiet); - else if (list) { + } else if (list) { int ret = print_ref_list(kinds, detached, verbose, abbrev, with_commit, argv); print_columns(&output, colopts, NULL); -- cgit v1.2.1 From 43722c4d9e04b3749372b13598b32cdceb1f1252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 28 Jan 2013 08:18:15 +0700 Subject: branch: give a more helpful message on redundant arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/branch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/branch.c') diff --git a/builtin/branch.c b/builtin/branch.c index 50fcaccab..531a21e83 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -859,7 +859,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) else if (argc == 1) branch_name = argv[0]; else - usage_with_options(builtin_branch_usage, options); + die(_("cannot edit description of more than one branch")); strbuf_addf(&branch_ref, "refs/heads/%s", branch_name); if (!ref_exists(branch_ref.buf)) { @@ -881,7 +881,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) else if (argc == 2) rename_branch(argv[0], argv[1], rename > 1); else - usage_with_options(builtin_branch_usage, options); + die(_("too many branches for a rename operation")); } else if (new_upstream) { struct branch *branch = branch_get(argv[0]); -- cgit v1.2.1 From 045e3884bc432aff651659dc60059d1e8c2f86ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 28 Jan 2013 08:18:16 +0700 Subject: branch: mark more strings for translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jonathan Nieder Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/branch.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'builtin/branch.c') diff --git a/builtin/branch.c b/builtin/branch.c index ca61c5ba5..597b578e1 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -466,7 +466,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_item *item, int verbose, int abbrev) { struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT; - const char *sub = " **** invalid ref ****"; + const char *sub = _(" **** invalid ref ****"); struct commit *commit = item->commit; if (commit && !parse_commit(commit)) { @@ -590,7 +590,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru struct commit *filter; filter = lookup_commit_reference_gently(merge_filter_ref, 0); if (!filter) - die("object '%s' does not point to a commit", + die(_("object '%s' does not point to a commit"), sha1_to_hex(merge_filter_ref)); filter->object.flags |= UNINTERESTING; @@ -854,7 +854,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (!argc) { if (detached) - die("Cannot give description to detached HEAD"); + die(_("Cannot give description to detached HEAD")); branch_name = head; } else if (argc == 1) branch_name = argv[0]; @@ -866,10 +866,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix) strbuf_release(&branch_ref); if (!argc) - return error("No commit on branch '%s' yet.", + return error(_("No commit on branch '%s' yet."), branch_name); else - return error("No such branch '%s'.", branch_name); + return error(_("No branch named '%s'."), + branch_name); } strbuf_release(&branch_ref); -- cgit v1.2.1 From d040350813986e0f4bb3aeb977077975c1552606 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 31 Jan 2013 01:46:11 -0500 Subject: branch: let branch filters imply --list Currently, a branch filter like `--contains`, `--merged`, or `--no-merged` is ignored when we are not in listing mode. For example: git branch --contains=foo bar will create the branch "bar" from the current HEAD, ignoring the `--contains` argument entirely. This is not very helpful. There are two reasonable behaviors for git here: 1. Flag an error; the arguments do not make sense. 2. Implicitly go into `--list` mode This patch chooses the latter, as it is more convenient, and there should not be any ambiguity with attempting to create a branch; using `--contains` and not wanting to list is nonsensical. That leaves the case where an explicit modification option like `-d` is given. We already catch the case where `--list` is given alongside `-d` and flag an error. With this patch, we will also catch the use of `--contains` and other filter options alongside `-d`. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/branch.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin/branch.c') diff --git a/builtin/branch.c b/builtin/branch.c index 597b578e1..bd2c36b70 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -825,6 +825,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (!delete && !rename && !edit_description && !new_upstream && !unset_upstream && argc == 0) list = 1; + if (with_commit || merge_filter != NO_FILTER) + list = 1; + if (!!delete + !!rename + !!force_create + !!list + !!new_upstream + !!unset_upstream > 1) usage_with_options(builtin_branch_usage, options); -- cgit v1.2.1