diff mbox series

grep: reject --no-or

Message ID 6aeb0ebe-0fea-ccd3-089a-ee0b5b5baf10@web.de (mailing list archive)
State Accepted
Commit aae8558b1038de452acee672dffca30339f65fa9
Headers show
Series grep: reject --no-or | expand

Commit Message

René Scharfe Sept. 7, 2023, 8:20 p.m. UTC
Since 3e230fa1b2 (grep: use parseopt, 2009-05-07) git grep has been
accepting the option --no-or.  It does the same as --or: nothing.
That's confusing and unintended.  Forbid negating --or.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 builtin/grep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.42.0

Comments

Junio C Hamano Sept. 7, 2023, 8:34 p.m. UTC | #1
René Scharfe <l.s.r@web.de> writes:

> Since 3e230fa1b2 (grep: use parseopt, 2009-05-07) git grep has been
> accepting the option --no-or.  It does the same as --or: nothing.
> That's confusing and unintended.  Forbid negating --or.

OK.  It is just a no-op Boolean but that is not a good reason for us
to be loose.  Will queue.  Thanks.

>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  builtin/grep.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/grep.c b/builtin/grep.c
> index 50e712a184..2a261074f1 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -990,7 +990,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>  		OPT_CALLBACK_F(0, "and", &opt, NULL,
>  			N_("combine patterns specified with -e"),
>  			PARSE_OPT_NOARG | PARSE_OPT_NONEG, and_callback),
> -		OPT_BOOL(0, "or", &dummy, ""),
> +		OPT_BOOL_F(0, "or", &dummy, "", PARSE_OPT_NONEG),
>  		OPT_CALLBACK_F(0, "not", &opt, NULL, "",
>  			PARSE_OPT_NOARG | PARSE_OPT_NONEG, not_callback),
>  		OPT_CALLBACK_F('(', NULL, &opt, NULL, "",
> --
> 2.42.0
diff mbox series

Patch

diff --git a/builtin/grep.c b/builtin/grep.c
index 50e712a184..2a261074f1 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -990,7 +990,7 @@  int cmd_grep(int argc, const char **argv, const char *prefix)
 		OPT_CALLBACK_F(0, "and", &opt, NULL,
 			N_("combine patterns specified with -e"),
 			PARSE_OPT_NOARG | PARSE_OPT_NONEG, and_callback),
-		OPT_BOOL(0, "or", &dummy, ""),
+		OPT_BOOL_F(0, "or", &dummy, "", PARSE_OPT_NONEG),
 		OPT_CALLBACK_F(0, "not", &opt, NULL, "",
 			PARSE_OPT_NOARG | PARSE_OPT_NONEG, not_callback),
 		OPT_CALLBACK_F('(', NULL, &opt, NULL, "",