From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 2/2] git-completion: use --git-completion-helper
Date: Tue, 16 Jan 2018 17:37:00 +0700 [thread overview]
Message-ID: <20180116103700.4505-3-pclouds@gmail.com> (raw)
In-Reply-To: <20180116103700.4505-1-pclouds@gmail.com>
The builtin command is updated to hide some options. The new options
that are complete-able are:
--after-context=
--all-match
--before-context=
--color
--context
--exclude-standard
--recurse-submodules
--textconv
--max-depth and --threads are already completable, but now it will
complete with the "=" suffix because these always take an argument.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/grep.c | 13 ++++++++-----
contrib/completion/git-completion.bash | 16 +---------------
parse-options.h | 8 +++++---
3 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index 3ca4ac80d8..8fe5560ee8 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -832,8 +832,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
OPT_BOOL('L', "files-without-match",
&opt.unmatch_name_only,
N_("show only the names of files without match")),
- OPT_BOOL('z', "null", &opt.null_following_name,
- N_("print NUL after filenames")),
+ OPT_BOOL_F('z', "null", &opt.null_following_name,
+ N_("print NUL after filenames"),
+ PARSE_OPT_NO_GITCOMP),
OPT_BOOL('c', "count", &opt.count,
N_("show the number of matches instead of matching lines")),
OPT__COLOR(&opt.color, N_("highlight matches")),
@@ -884,9 +885,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
OPT_GROUP(""),
{ OPTION_STRING, 'O', "open-files-in-pager", &show_in_pager,
N_("pager"), N_("show matching files in the pager"),
- PARSE_OPT_OPTARG, NULL, (intptr_t)default_pager },
- OPT_BOOL(0, "ext-grep", &external_grep_allowed__ignored,
- N_("allow calling of grep(1) (ignored by this build)")),
+ PARSE_OPT_OPTARG | PARSE_OPT_NO_GITCOMP,
+ NULL, (intptr_t)default_pager },
+ OPT_BOOL_F(0, "ext-grep", &external_grep_allowed__ignored,
+ N_("allow calling of grep(1) (ignored by this build)"),
+ PARSE_OPT_NO_GITCOMP),
OPT_END()
};
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3683c772c5..f0d9126fd6 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1585,21 +1585,7 @@ _git_grep ()
case "$cur" in
--*)
- __gitcomp "
- --cached
- --text --ignore-case --word-regexp --invert-match
- --full-name --line-number
- --extended-regexp --basic-regexp --fixed-strings
- --perl-regexp
- --threads
- --files-with-matches --name-only
- --files-without-match
- --max-depth
- --count
- --and --or --not --all-match
- --break --heading --show-function --function-context
- --untracked --no-index
- "
+ __gitcomp "$(git grep --git-completion-helper)"
return
;;
esac
diff --git a/parse-options.h b/parse-options.h
index 8a3389b05b..2bd833a4c5 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -124,9 +124,11 @@ struct option {
(h), PARSE_OPT_NOARG, NULL, (b) }
#define OPT_COUNTUP(s, l, v, h) { OPTION_COUNTUP, (s), (l), (v), NULL, \
(h), PARSE_OPT_NOARG }
-#define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, \
- (h), PARSE_OPT_NOARG, NULL, (i) }
-#define OPT_BOOL(s, l, v, h) OPT_SET_INT(s, l, v, h, 1)
+#define OPT_SET_INT_F(s, l, v, h, i, f) { OPTION_SET_INT, (s), (l), (v), NULL, \
+ (h), PARSE_OPT_NOARG | (f), NULL, (i) }
+#define OPT_SET_INT(s, l, v, h, i) OPT_SET_INT_F(s, l, v, h, i, 0)
+#define OPT_BOOL_F(s, l, v, h, f) OPT_SET_INT_F(s, l, v, h, 1, f)
+#define OPT_BOOL(s, l, v, h) OPT_BOOL_F(s, l, v, h, 0)
#define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \
(h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}
#define OPT_CMDMODE(s, l, v, h, i) { OPTION_CMDMODE, (s), (l), (v), NULL, \
--
2.15.1.600.g899a5f85c6
next prev parent reply other threads:[~2018-01-16 10:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-16 10:36 [PATCH/RFC 0/2] Automate updating git-completion.bash a bit Nguyễn Thái Ngọc Duy
2018-01-16 10:36 ` [PATCH 1/2] parse-options: support --git-completion-helper Nguyễn Thái Ngọc Duy
2018-01-16 18:25 ` Jacob Keller
2018-01-17 0:21 ` Duy Nguyen
2018-01-16 23:46 ` Junio C Hamano
2018-01-17 0:27 ` Duy Nguyen
2018-01-16 10:37 ` Nguyễn Thái Ngọc Duy [this message]
2018-01-17 0:51 ` [PATCH/RFC 0/2] Automate updating git-completion.bash a bit SZEDER Gábor
2018-01-17 9:16 ` Duy Nguyen
2018-01-17 9:34 ` Duy Nguyen
2018-01-22 18:03 ` SZEDER Gábor
2018-01-23 9:59 ` Duy Nguyen
2019-04-11 11:10 ` Duy Nguyen
2019-04-11 11:11 ` Duy Nguyen
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180116103700.4505-3-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=szeder.dev@gmail.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).