nd/command-list updates
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest17 patches 1 replyIn review
- v114 patches 6 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/17 | generate-cmds.sh: factor out synopsis extract codegenerate-cmdlist.sh | +11 | 0 replies | |
| 2/17 | generate-cmds.sh: export all commands to command-list.h.gitignore Makefile command-list.txt +1 more | +75 | 0 replies | |
| 3/17 | help: use command-list.h for common command listMakefile command-list.txt generate-cmdlist.sh +2 more | +122 | 0 replies | |
| 4/17 | Remove common-cmds.h.gitignore Makefile generate-cmdlist.sh | +9 | 0 replies | |
| 5/17 | git.c: convert --list-* to --list-cmds=*Documentation/ contrib/ git.c +1 more | +39 | 0 replies | |
| 6/17 | git --list-cmds: collect command list in a string_listgit.c | +17 | 0 replies | |
| 7/17 | completion: implement and use --list-cmds=main,othersDocumentation/ contrib/ git.c +2 more | +43 | 0 replies | |
| 8/17 | git: support --list-cmds=list-<category>Documentation/ generate-cmdlist.sh git.c +2 more | +51 | 0 replies | |
| 9/17 | help: add "-a --verbose" to list all commands with synopsisDocumentation/ builtin/ help.c +2 more | +37 | 0 replies | |
| 10/17 | help: use command-list.txt for the source of guidesDocumentation/ Documentation/ Documentation/ +7 more | +54 | 1 reply | |
| 11/17 | command-list.txt: documentation and guide linecommand-list.txt | +45 | 0 replies | |
| 12/17 | completion: let git provide the completable command listcommand-list.txt contrib/ t/ | +58 | 0 replies | |
| 13/17 | completion: reduce completable command listcommand-list.txt | +9 | 0 replies | |
| 14/17 | Move declaration for alias.c to alias.halias.c alias.h builtin/ +7 more | +17 | 0 replies | |
| 15/17 | completion: add and use --list-cmds=nohelpersDocumentation/ contrib/ git.c | +20 | 0 replies | |
| 16/17 | completion: add and use --list-cmds=aliasDocumentation/ alias.c alias.h +3 more | +40 | 0 replies | |
| 17/17 | completion: allow to customize the completable command listDocumentation/ Documentation/ contrib/ +3 more | +47 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 00/17] nd/command-list updates
It turns out this series is not done as I thought it was :)
v2 makes it possible to write
gitcomp "$(git --list-cmds=...)"
which is really nice and very close to what gitcomp_builtin does. Other changes are
- support --list-cmds=alias and --list-cmds=nohelpers so that we could do the above
- a bit more document about --list-cmds
- $GIT_COMPLETION_CMD_GROUPS is dropped. I think it just causes more confusion and complete.commands should be enough in most cases
- name-rev is no longer compleable
- "git help <tab>" does not show truly external commands anymore (those that are in $PATH but not in libexec and very unlikely to have a man page)
Documentation/config.txt +2 -4
@@ -1345,13 +1345,11 @@ credentialCache.ignoreSIGHUP:: completion.commands:: This is only used by git-completion.bash to add or remove - commands from the complete list. Normally only porcelain - commands and a few select others are in the complete list. You + commands from the list of completed commands. Normally only + porcelain commands and a few select others are completed. You can add more commands, separated by space, in this variable. Prefixing the command with '-' will remove it from the existing list. -+ -This variable should not be per-repository. include::diff-config.txt[]
Documentation/git.txt +10 -0
@@ -163,6 +163,16 @@ foo.bar= ...`) sets `foo.bar` to the empty string which `git config Do not perform optional operations that require locks. This is equivalent to setting the `GIT_OPTIONAL_LOCKS` to `0`. +--list-cmds=group[,group...]:: + List commands by group. This is an internal/experimental + option and may change or be removed in the future. Supported + groups are: builtins, parseopt (builtin commands that use + parse-options), main (all commands in libexec directory), + others (all other commands in `$PATH` that have git- prefix), + list-<category> (see categories in command-list.txt), + nohelpers (exclude helper commands), alias and config + (retrieve command list from config variable completion.commands) + GIT COMMANDS ------------
alias.c +20 -2
@@ -1,9 +1,12 @@#include "cache.h" +#include "alias.h" #include "config.h" +#include "string-list.h" struct config_alias_data {const char *alias;char *v; +struct string_list *list; };static int config_alias_cb (const char *key,const char *value,void *d)
@@ -11,8 +14,16 @@ static int config_alias_cb(const char *key, const char *value, void *d)struct config_alias_data *data = d;const char *p; -if (skip_prefix (key,"alias." , &p) && !strcasecmp (p, data->alias)) -return git_config_string ((const char **)&data->v, key, value); +if (!skip_prefix (key,"alias." , &p)) +return 0 ; + +if (data->alias) { +if (!strcasecmp (p, data->alias)) +return git_config_string ((const char **)&data->v, + key, value); + }else if (data->list) { +string_list_append (data->list, p); + }return 0 ; }
@@ -26,6 +37,13 @@ char *alias_lookup(const char *alias)return data.v; } +void list_aliases (struct string_list *list) +{ +struct config_alias_data data = {NULL ,NULL , list }; + +read_early_config (config_alias_cb, &data); +} +#define SPLIT_CMDLINE_BAD_ENDING 1#define SPLIT_CMDLINE_UNCLOSED_QUOTE 2static const char *split_cmdline_errors[] = {
alias.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ALIAS_H__ +#define __ALIAS_H__ + +struct string_list ; + +char *alias_lookup (const char *alias); +int split_cmdline (char *cmdline,const char ***argv); +/* Takes a negative value returned by split_cmdline */ +const char *split_cmdline_strerror (int cmdline_errno); +void list_aliases (struct string_list *list); + +#endif
builtin/help.c +1 -0
@@ -9,6 +9,7 @@#include "run-command.h" #include "column.h" #include "help.h" +#include "alias.h" #ifndef DEFAULT_HELP_FORMAT #define DEFAULT_HELP_FORMAT "man"
builtin/merge.c +1 -0
@@ -34,6 +34,7 @@#include "string-list.h" #include "packfile.h" #include "tag.h" +#include "alias.h" #define DEFAULT_TWOHEAD (1<<0)#define DEFAULT_OCTOPUS (1<<1)
cache.h +0 -5
@@ -1835,11 +1835,6 @@ extern int ws_blank_line(const char *line, int len, unsigned ws_rule);void overlay_tree_on_index (struct index_state *istate,const char *tree_name,const char *prefix); -char *alias_lookup (const char *alias); -int split_cmdline (char *cmdline,const char ***argv); -/* Takes a negative value returned by split_cmdline */ -const char *split_cmdline_strerror (int cmdline_errno); -/* setup.c */ struct startup_info {int have_repository;
command-list.txt +1 -1
@@ -125,7 +125,7 @@ git-merge-tree ancillaryinterrogators git-mktag plumbingmanipulators git-mktree plumbingmanipulators git-mv mainporcelain worktree -git-name-rev plumbinginterrogators complete +git-name-rev plumbinginterrogators git-notes mainporcelain git-p4 foreignscminterface git-pack-objects plumbingmanipulators
connect.c +1 -0
@@ -13,6 +13,7 @@#include "transport.h" #include "strbuf.h" #include "protocol.h" +#include "alias.h" static char *server_capabilities;static const char *parse_feature_value (const char *,const char *,int *);
contrib/completion/git-completion.bash +15 -98
153 lines not on this page · raw message
git.c +17 -0
@@ -3,6 +3,7 @@#include "exec_cmd.h" #include "help.h" #include "run-command.h" +#include "alias.h" #define RUN_SETUP (1<<0)#define RUN_SETUP_GENTLY (1<<1)
@@ -38,6 +39,18 @@ static int use_pager = -1;static void list_builtins (struct string_list *list,unsigned int exclude_option); +static void exclude_helpers_from_list (struct string_list *list) +{ +int i =0 ; + +while (i < list->nr) { +if (strstr (list->items[i].string,"--" )) +unsorted_string_list_delete_item (list, i,0 ); +else + i++; + } +} +static int match_token (const char *spec,int len,const char *token) {int token_len =strlen (token);
@@ -60,6 +73,10 @@ static int list_cmds(const char *spec)list_all_main_cmds (&list); else if (match_token(spec, len, "others")) list_all_other_cmds(&list); + else if (match_token(spec, len, "nohelpers")) + exclude_helpers_from_list(&list); + else if (match_token(spec, len, "alias")) + list_aliases(&list); else if (match_token(spec, len, "config")) list_cmds_by_config(&list); else if (len > 5 && !strncmp(spec, "list-", 5)) {
pager.c +1 -0
@@ -2,6 +2,7 @@#include "config.h" #include "run-command.h" #include "sigchain.h" +#include "alias.h" #ifndef DEFAULT_PAGER #define DEFAULT_PAGER "less"
sequencer.c +1 -0
@@ -23,6 +23,7 @@#include "hashmap.h" #include "notes-utils.h" #include "sigchain.h" +#include "alias.h" #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
shell.c +1 -0
@@ -3,6 +3,7 @@#include "exec_cmd.h" #include "strbuf.h" #include "run-command.h" +#include "alias.h" #define COMMAND_DIR "git-shell-commands"#define HELP_COMMAND COMMAND_DIR "/help"
t/t9902-completion.sh +0 -18
@@ -1192,17 +1192,6 @@ test_expect_success '__git_pretty_aliases' ' test_cmp expect actual ' -test_expect_success '__git_aliases' ' - cat >expect <<-EOF && - ci - co - EOF - test_config alias.ci commit && - test_config alias.co checkout && - __git_aliases >actual && - test_cmp expect actual -' - test_expect_success 'basic' ' run_completion "git " && # built-in
@@ -1511,13 +1500,6 @@ test_expect_success 'sourcing the completion script clears cached commands' ' verbose test -z "$__git_all_commands" ' -test_expect_success 'sourcing the completion script clears cached porcelain commands' ' - __git_compute_porcelain_commands && - verbose test -n "$__git_porcelain_commands" && - . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" && - verbose test -z "$__git_porcelain_commands" -' - test_expect_success !GETTEXT_POISON 'sourcing the completion script clears cached merge strategies' ' __git_compute_merge_strategies && verbose test -n "$__git_merge_strategies" &&
Nguyễn Thái Ngọc Duy (17):
generate-cmds.sh: factor out synopsis extract code generate-cmds.sh: export all commands to command-list.h
help: use command-list.h for common command list Remove common-cmds.h
git.c: convert --list-* to --list-cmds=*
git --list-cmds: collect command list in a string_list
completion: implement and use --list-cmds=main,others
git: support --list-cmds=list-<category>
help: add "-a --verbose" to list all commands with synopsis
help: use command-list.txt for the source of guides command-list.txt: documentation and guide line
completion: let git provide the completable command list
completion: reduce completable command list
Move declaration for alias.c to alias.h
completion: add and use --list-cmds=nohelpers
completion: add and use --list-cmds=alias
completion: allow to customize the completable command list
.gitignore | 2 +- Documentation/config.txt | 8 + Documentation/git-help.txt | 4 +- Documentation/git.txt | 10 + Documentation/gitattributes.txt | 2 +- Documentation/gitmodules.txt | 2 +- Documentation/gitrevisions.txt | 2 +- Makefile | 16 +- alias.c | 22 ++- alias.h | 12 ++ builtin/help.c | 40 +--- builtin/merge.c | 1 + cache.h | 5 - command-list.txt | 110 ++++++++--- connect.c | 1 + contrib/completion/git-completion.bash | 147 ++------------- generate-cmdlist.sh | 126 ++++++++----- git.c | 85 ++++++++- help.c | 244 ++++++++++++++++++++++--- help.h | 10 + pager.c | 1 + sequencer.c | 1 + shell.c | 1 + t/t0012-help.sh | 26 ++- t/t9902-completion.sh | 23 +-- 25 files changed, 589 insertions(+), 312 deletions(-) create mode 100644 alias.h
Signature · 1 line
2.17.0.705.g3525833791