From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 2/3] branch: give a more helpful message on redundant arguments
Date: Fri, 25 Jan 2013 19:50:24 +0700 [thread overview]
Message-ID: <1359118225-14356-2-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1359118225-14356-1-git-send-email-pclouds@gmail.com>
While at there, do not stop user from editing a branch description
when the unrelated HEAD is detached.
---
builtin/branch.c | 12 ++++++------
t/t3200-branch.sh | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 50fcacc..ca61c5b 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -852,14 +852,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
const char *branch_name;
struct strbuf branch_ref = STRBUF_INIT;
- if (detached)
- die("Cannot give description to detached HEAD");
- if (!argc)
+ if (!argc) {
+ if (detached)
+ die("Cannot give description to detached HEAD");
branch_name = head;
- else if (argc == 1)
+ } 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]);
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 80e6be3..f3e0e4a 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -73,8 +73,8 @@ test_expect_success \
test_expect_success \
'git branch -m dumps usage' \
- 'test_expect_code 129 git branch -m 2>err &&
- test_i18ngrep "[Uu]sage: git branch" err'
+ 'test_expect_code 128 git branch -m 2>err &&
+ test_i18ngrep "too many branches for a rename operation" err'
test_expect_success \
'git branch -m m m/m should work' \
--
1.8.0.rc2.23.g1fb49df
next prev parent reply other threads:[~2013-01-25 12:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 8:26 [PATCH] branch: reject -D/-d without branch name Nguyễn Thái Ngọc Duy
2013-01-25 8:45 ` Matthieu Moy
2013-01-25 8:56 ` Duy Nguyen
2013-01-25 12:50 ` [PATCH v2 1/3] " Nguyễn Thái Ngọc Duy
2013-01-25 12:50 ` Nguyễn Thái Ngọc Duy [this message]
2013-01-27 11:58 ` [PATCH v2 2/3] branch: give a more helpful message on redundant arguments Jonathan Nieder
2013-01-25 12:50 ` [PATCH v2 3/3] branch: mark more strings for translation Nguyễn Thái Ngọc Duy
2013-01-27 11:55 ` Jonathan Nieder
2013-01-25 19:04 ` [PATCH v2 1/3] branch: reject -D/-d without branch name Junio C Hamano
2013-01-26 3:12 ` Duy Nguyen
2013-01-28 1:18 ` [PATCH v3 1/4] branch: no detached HEAD check when editing another branch's description Nguyễn Thái Ngọc Duy
2013-01-28 1:18 ` [PATCH v3 2/4] branch: reject -D/-d without branch name Nguyễn Thái Ngọc Duy
2013-01-28 1:18 ` [PATCH v3 3/4] branch: give a more helpful message on redundant arguments Nguyễn Thái Ngọc Duy
2013-01-28 1:18 ` [PATCH v3 4/4] branch: mark more strings for translation Nguyễn Thái Ngọc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1359118225-14356-2-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.