From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: pclouds@gmail.com
Cc: git@vger.kernel.org, szeder.dev@gmail.com,
Eric Sunshine <sunshine@sunshineco.com>,
philipoakley@iee.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 4/6] git.c: implement --list-cmds=porcelain
Date: Sun, 15 Apr 2018 18:42:36 +0200 [thread overview]
Message-ID: <20180415164238.9107-5-pclouds@gmail.com> (raw)
In-Reply-To: <20180415164238.9107-1-pclouds@gmail.com>
This is useful for git-completion.bash because it needs this set of
commands. Right now we have to maintain a separate command category in
there.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
contrib/completion/git-completion.bash | 94 ++------------------------
git.c | 2 +
help.c | 12 ++++
help.h | 1 +
t/t9902-completion.sh | 4 +-
5 files changed, 20 insertions(+), 93 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a5f13ade20..9f17703aa7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -839,14 +839,15 @@ __git_commands () {
then
printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
else
- git --list-cmds=all
+ git --list-cmds=$1
fi
}
__git_list_all_commands ()
{
local i IFS=" "$'\n'
- for i in $(__git_commands)
+ local category=${1-all}
+ for i in $(__git_commands $category)
do
case $i in
*--*) : helper pattern;;
@@ -862,98 +863,11 @@ __git_compute_all_commands ()
__git_all_commands=$(__git_list_all_commands)
}
-__git_list_porcelain_commands ()
-{
- local i IFS=" "$'\n'
- __git_compute_all_commands
- for i in $__git_all_commands
- do
- case $i in
- *--*) : helper pattern;;
- applymbox) : ask gittus;;
- applypatch) : ask gittus;;
- archimport) : import;;
- cat-file) : plumbing;;
- check-attr) : plumbing;;
- check-ignore) : plumbing;;
- check-mailmap) : plumbing;;
- check-ref-format) : plumbing;;
- checkout-index) : plumbing;;
- column) : internal helper;;
- commit-tree) : plumbing;;
- count-objects) : infrequent;;
- credential) : credentials;;
- credential-*) : credentials helper;;
- cvsexportcommit) : export;;
- cvsimport) : import;;
- cvsserver) : daemon;;
- daemon) : daemon;;
- diff-files) : plumbing;;
- diff-index) : plumbing;;
- diff-tree) : plumbing;;
- fast-import) : import;;
- fast-export) : export;;
- fsck-objects) : plumbing;;
- fetch-pack) : plumbing;;
- fmt-merge-msg) : plumbing;;
- for-each-ref) : plumbing;;
- hash-object) : plumbing;;
- http-*) : transport;;
- index-pack) : plumbing;;
- init-db) : deprecated;;
- local-fetch) : plumbing;;
- ls-files) : plumbing;;
- ls-remote) : plumbing;;
- ls-tree) : plumbing;;
- mailinfo) : plumbing;;
- mailsplit) : plumbing;;
- merge-*) : plumbing;;
- mktree) : plumbing;;
- mktag) : plumbing;;
- pack-objects) : plumbing;;
- pack-redundant) : plumbing;;
- pack-refs) : plumbing;;
- parse-remote) : plumbing;;
- patch-id) : plumbing;;
- prune) : plumbing;;
- prune-packed) : plumbing;;
- quiltimport) : import;;
- read-tree) : plumbing;;
- receive-pack) : plumbing;;
- remote-*) : transport;;
- rerere) : plumbing;;
- rev-list) : plumbing;;
- rev-parse) : plumbing;;
- runstatus) : plumbing;;
- sh-setup) : internal;;
- shell) : daemon;;
- show-ref) : plumbing;;
- send-pack) : plumbing;;
- show-index) : plumbing;;
- ssh-*) : transport;;
- stripspace) : plumbing;;
- symbolic-ref) : plumbing;;
- unpack-file) : plumbing;;
- unpack-objects) : plumbing;;
- update-index) : plumbing;;
- update-ref) : plumbing;;
- update-server-info) : daemon;;
- upload-archive) : plumbing;;
- upload-pack) : plumbing;;
- write-tree) : plumbing;;
- var) : infrequent;;
- verify-pack) : infrequent;;
- verify-tag) : plumbing;;
- *) echo $i;;
- esac
- done
-}
-
__git_porcelain_commands=
__git_compute_porcelain_commands ()
{
test -n "$__git_porcelain_commands" ||
- __git_porcelain_commands=$(__git_list_porcelain_commands)
+ __git_porcelain_commands=$(__git_list_all_commands porcelain)
}
# Lists all set config variables starting with the given section prefix,
diff --git a/git.c b/git.c
index 64f67e7f7f..153f56fb95 100644
--- a/git.c
+++ b/git.c
@@ -230,6 +230,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
list_builtins(NO_PARSEOPT, ' ');
else if (!strcmp(cmd, "all"))
list_all_cmds();
+ else if (!strcmp(cmd, "porcelain"))
+ list_porcelain_cmds();
else
die("unsupported command listing type '%s'", cmd);
exit(0);
diff --git a/help.c b/help.c
index b5da7fa013..1523ca175c 100644
--- a/help.c
+++ b/help.c
@@ -272,6 +272,18 @@ void list_all_cmds(void)
clean_cmdnames(&other_cmds);
}
+void list_porcelain_cmds(void)
+{
+ int i, nr = ARRAY_SIZE(command_list);
+ struct cmdname_help *cmds = command_list;
+
+ for (i = 0; i < nr; i++) {
+ if (cmds[i].category != CAT_mainporcelain)
+ continue;
+ puts(cmds[i].name);
+ }
+}
+
int is_in_cmdlist(struct cmdnames *c, const char *s)
{
int i;
diff --git a/help.h b/help.h
index 0bf29f8dc5..33e2210ebd 100644
--- a/help.h
+++ b/help.h
@@ -18,6 +18,7 @@ static inline void mput_char(char c, unsigned int num)
extern void list_common_cmds_help(void);
extern void list_all_cmds(void);
+extern void list_porcelain_cmds(void);
extern const char *help_unknown_cmd(const char *cmd);
extern void load_command_list(const char *prefix,
struct cmdnames *main_cmds,
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 1b34caa1e1..4bfd26ddf9 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1208,8 +1208,6 @@ test_expect_success 'basic' '
grep -q "^add \$" out &&
# script
grep -q "^filter-branch \$" out &&
- # plumbing
- ! grep -q "^ls-files \$" out &&
run_completion "git f" &&
! grep -q -v "^f" out
@@ -1272,7 +1270,7 @@ test_expect_success 'general options' '
test_completion "git --no-r" "--no-replace-objects "
'
-test_expect_success 'general options plus command' '
+test_expect_failure 'general options plus command' '
test_completion "git --version check" "checkout " &&
test_completion "git --paginate check" "checkout " &&
test_completion "git --git-dir=foo check" "checkout " &&
--
2.17.0.367.g5dd2e386c3
next prev parent reply other threads:[~2018-04-15 16:45 UTC|newest]
Thread overview: 137+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 1/5] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 2/5] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
2018-04-09 3:32 ` Eric Sunshine
2018-03-26 16:55 ` [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-09 4:59 ` Eric Sunshine
2018-04-09 5:12 ` Eric Sunshine
2018-04-09 16:16 ` Duy Nguyen
2018-04-15 16:04 ` Duy Nguyen
2018-03-26 16:55 ` [PATCH/RFC 4/5] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-09 5:08 ` Eric Sunshine
2018-04-09 9:47 ` Junio C Hamano
2018-04-09 9:55 ` Eric Sunshine
2018-04-09 15:15 ` Duy Nguyen
2018-04-09 5:17 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Eric Sunshine
2018-04-11 22:06 ` Philip Oakley
2018-04-14 15:44 ` Duy Nguyen
2018-04-15 21:21 ` Philip Oakley
2018-04-17 16:24 ` Duy Nguyen
2018-04-17 16:48 ` Duy Nguyen
2018-04-17 22:47 ` Philip Oakley
2018-04-18 6:38 ` Philip Oakley
2018-04-18 15:33 ` Duy Nguyen
2018-04-19 7:47 ` Philip Oakley
2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
2018-04-15 16:42 ` [PATCH v2 1/6] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
2018-04-15 16:42 ` [PATCH v2 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
2018-04-16 2:30 ` Junio C Hamano
2018-04-15 16:42 ` [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-16 2:38 ` Junio C Hamano
2018-04-23 8:23 ` Øystein Walle
2018-04-23 9:59 ` SZEDER Gábor
2018-04-16 6:28 ` Junio C Hamano
2018-04-16 15:43 ` Duy Nguyen
2018-04-16 15:43 ` SZEDER Gábor
2018-04-16 16:25 ` Ramsay Jones
2018-04-16 22:42 ` Junio C Hamano
2018-04-15 16:42 ` Nguyễn Thái Ngọc Duy [this message]
2018-04-15 16:42 ` [PATCH v2 5/6] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-15 16:42 ` [PATCH v2 6/6] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 0/6] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 1/6] git.c: convert --list-*builtins to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
2018-04-23 11:20 ` SZEDER Gábor
2018-04-21 16:54 ` [PATCH v3 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 4/6] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
2018-04-23 13:32 ` SZEDER Gábor
2018-04-24 16:12 ` Duy Nguyen
2018-04-24 16:17 ` Duy Nguyen
2018-04-25 13:46 ` SZEDER Gábor
2018-04-25 14:44 ` Duy Nguyen
2018-04-25 13:06 ` SZEDER Gábor
2018-04-25 14:39 ` Duy Nguyen
2018-04-21 16:54 ` [PATCH v3 5/6] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-21 16:54 ` [PATCH v3 6/6] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-23 6:07 ` Eric Sunshine
2018-04-21 16:56 ` [PATCH v3 0/6] Keep all info in command-list.txt in git binary Duy Nguyen
2018-04-22 14:45 ` Ramsay Jones
2018-04-22 15:22 ` Duy Nguyen
2018-04-22 15:58 ` Ramsay Jones
2018-04-22 16:12 ` Duy Nguyen
2018-04-22 16:36 ` Ramsay Jones
2018-04-25 16:30 ` [PATCH v4/wip 00/12] " Nguyễn Thái Ngọc Duy
2018-04-25 16:30 ` [PATCH v4/wip 01/12] generate-cmds.sh: factor out synopsis extract code Nguyễn Thái Ngọc Duy
2018-04-25 17:59 ` Eric Sunshine
2018-04-25 18:13 ` SZEDER Gábor
2018-04-25 16:30 ` [PATCH v4/wip 02/12] generate-cmds.sh: export all commands to command-list.h Nguyễn Thái Ngọc Duy
2018-04-25 18:07 ` Eric Sunshine
2018-04-29 16:11 ` Duy Nguyen
2018-04-25 16:30 ` [PATCH v4/wip 03/12] help: use command-list.h for common command list Nguyễn Thái Ngọc Duy
2018-04-25 16:30 ` [PATCH v4/wip 04/12] Remove common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 05/12] git.c: convert --list-*builtins to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 06/12] git: accept multiple --list-cmds options Nguyễn Thái Ngọc Duy
2018-04-25 18:12 ` Eric Sunshine
2018-04-25 16:31 ` [PATCH v4/wip 07/12] completion: implement and use --list-cmds=all Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 08/12] git: support --list-cmds=<category> Nguyễn Thái Ngọc Duy
2018-04-25 18:16 ` Eric Sunshine
2018-04-25 16:31 ` [PATCH v4/wip 09/12] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 10/12] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-25 18:22 ` Eric Sunshine
2018-04-25 16:31 ` [PATCH v4/wip 11/12] command-list.txt: add new category "complete" Nguyễn Thái Ngọc Duy
2018-04-25 16:31 ` [PATCH v4/wip 12/12] completion: let git provide the completable command list Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 00/10] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 01/10] generate-cmds.sh: factor out synopsis extract code Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 02/10] generate-cmds.sh: export all commands to command-list.h Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 03/10] help: use command-list.h for common command list Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 04/10] Remove common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 05/10] git.c: convert --list-*builtins to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 06/10] completion: implement and use --list-cmds=main,others Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 07/10] git: support --list-cmds=list-<category> Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 08/10] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-29 18:18 ` [PATCH v5 09/10] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-29 18:23 ` Duy Nguyen
2018-04-29 18:18 ` [PATCH v5 10/10] completion: let git provide the completable command list Nguyễn Thái Ngọc Duy
2018-04-30 15:53 ` [PATCH v5 00/10] Keep all info in command-list.txt in git binary Duy Nguyen
2018-05-07 17:52 ` [PATCH v6 00/13] " Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 01/13] generate-cmds.sh: factor out synopsis extract code Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 02/13] generate-cmds.sh: export all commands to command-list.h Nguyễn Thái Ngọc Duy
2018-05-08 3:47 ` Junio C Hamano
2018-05-07 17:52 ` [PATCH v6 03/13] help: use command-list.h for common command list Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 04/13] Remove common-cmds.h Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 05/13] git.c: convert --list-* to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-05-08 3:50 ` Junio C Hamano
2018-05-07 17:52 ` [PATCH v6 06/13] git --list-cmds: collect command list in a string_list Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 07/13] completion: implement and use --list-cmds=main,others Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 08/13] git: support --list-cmds=list-<category> Nguyễn Thái Ngọc Duy
2018-05-08 4:00 ` Junio C Hamano
2018-05-07 17:52 ` [PATCH v6 09/13] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 10/13] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-05-08 4:04 ` Junio C Hamano
2018-05-07 17:52 ` [PATCH v6 11/13] command-list.txt: documentation and guide line Nguyễn Thái Ngọc Duy
2018-05-12 17:50 ` Philip Oakley
2018-05-07 17:52 ` [PATCH v6 12/13] completion: let git provide the completable command list Nguyễn Thái Ngọc Duy
2018-05-07 17:52 ` [PATCH v6 13/13] completion: allow to customize " Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 00/13] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 01/13] generate-cmds.sh: factor out synopsis extract code Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 02/13] generate-cmds.sh: export all commands to command-list.h Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 03/13] help: use command-list.h for common command list Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 04/13] Remove common-cmds.h Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 05/13] git.c: convert --list-* to --list-cmds=* Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 06/13] git --list-cmds: collect command list in a string_list Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 07/13] completion: implement and use --list-cmds=main,others Nguyễn Thái Ngọc Duy
2018-05-11 14:06 ` SZEDER Gábor
2018-05-11 14:32 ` SZEDER Gábor
2018-05-11 16:33 ` Duy Nguyen
2018-05-10 8:46 ` [PATCH v7 08/13] git: support --list-cmds=list-<category> Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 09/13] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 10/13] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 11/13] command-list.txt: documentation and guide line Nguyễn Thái Ngọc Duy
2018-05-10 8:46 ` [PATCH v7 12/13] completion: let git provide the completable command list Nguyễn Thái Ngọc Duy
2018-05-11 15:05 ` SZEDER Gábor
2018-05-13 6:50 ` Duy Nguyen
2018-05-10 8:46 ` [PATCH v7 13/13] completion: allow to customize " Nguyễn Thái Ngọc Duy
2018-04-19 10:37 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Simon Ruderich
2018-04-19 11:26 ` SZEDER Gábor
2018-04-20 7:05 ` Simon Ruderich
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=20180415164238.9107-5-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=philipoakley@iee.org \
--cc=sunshine@sunshineco.com \
--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).