[PATCH v2 1/3] branch: reject -D/-d without branch name

2013-01-25 Thread Nguyễn Thái Ngọc Duy
---
 builtin/branch.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 873f624..50fcacc 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);
-- 
1.8.0.rc2.23.g1fb49df

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/3] branch: reject -D/-d without branch name

2013-01-25 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy pclo...@gmail.com writes:

 ---
  builtin/branch.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

Forgot to sign-off?

Is this a real problem?

I do not see it particularly wrong to succeed after deleting 0 or
more given branch names.


 diff --git a/builtin/branch.c b/builtin/branch.c
 index 873f624..50fcacc 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);
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/3] branch: reject -D/-d without branch name

2013-01-25 Thread Duy Nguyen
On Sat, Jan 26, 2013 at 2:04 AM, Junio C Hamano gits...@pobox.com wrote:
 Nguyễn Thái Ngọc Duy pclo...@gmail.com writes:

 ---
  builtin/branch.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

 Forgot to sign-off?

Yes

 Is this a real problem?

Yes. My thoughts yesterday when I happened to type git branch -D:

Wait, I just entered a delete command without a branch name. It did
not report anything, which in UNIX world usually means successful
operation. _What_ did it delete??

I knew this code so I just went check. If I did not know, I might as
well list all branches I had and see if something was missing. A short
message would have saved me the trouble.

 I do not see it particularly wrong to succeed after deleting 0 or
 more given branch names.
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html