From 66fa6e8ed8bcfff6708d7bceed4c2b9e4050ebe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Fri, 19 Aug 2022 18:03:52 +0200 Subject: git.c: update NO_PARSEOPT markings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our Bash completion script can complete --options for commands using parse-options even when that command doesn't have a dedicated completion function, but to do so the completion script must know which commands use parse-options and which don't. Therefore, commands not using parse-options are marked in 'git.c's command list with the NO_PARSEOPT flag. Update this list, and remove this flag from the commands that by now use parse-options. After this change we can TAB complete --options of the plumbing commands 'commit-tree', 'mailinfo' and 'mktag'. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- git.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'git.c') diff --git a/git.c b/git.c index e5d62fa5a9..09c126c33d 100644 --- a/git.c +++ b/git.c @@ -489,14 +489,14 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) static struct cmd_struct commands[] = { { "add", cmd_add, RUN_SETUP | NEED_WORK_TREE }, { "am", cmd_am, RUN_SETUP | NEED_WORK_TREE }, - { "annotate", cmd_annotate, RUN_SETUP | NO_PARSEOPT }, + { "annotate", cmd_annotate, RUN_SETUP }, { "apply", cmd_apply, RUN_SETUP_GENTLY }, { "archive", cmd_archive, RUN_SETUP_GENTLY }, { "bisect--helper", cmd_bisect__helper, RUN_SETUP }, { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG }, { "bugreport", cmd_bugreport, RUN_SETUP_GENTLY }, - { "bundle", cmd_bundle, RUN_SETUP_GENTLY | NO_PARSEOPT }, + { "bundle", cmd_bundle, RUN_SETUP_GENTLY }, { "cat-file", cmd_cat_file, RUN_SETUP }, { "check-attr", cmd_check_attr, RUN_SETUP }, { "check-ignore", cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE }, @@ -514,7 +514,7 @@ static struct cmd_struct commands[] = { { "column", cmd_column, RUN_SETUP_GENTLY }, { "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE }, { "commit-graph", cmd_commit_graph, RUN_SETUP }, - { "commit-tree", cmd_commit_tree, RUN_SETUP | NO_PARSEOPT }, + { "commit-tree", cmd_commit_tree, RUN_SETUP }, { "config", cmd_config, RUN_SETUP_GENTLY | DELAY_PAGER_CONFIG }, { "count-objects", cmd_count_objects, RUN_SETUP }, { "credential", cmd_credential, RUN_SETUP_GENTLY | NO_PARSEOPT }, @@ -553,7 +553,7 @@ static struct cmd_struct commands[] = { { "ls-files", cmd_ls_files, RUN_SETUP }, { "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY }, { "ls-tree", cmd_ls_tree, RUN_SETUP }, - { "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY | NO_PARSEOPT }, + { "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY }, { "mailsplit", cmd_mailsplit, NO_PARSEOPT }, { "maintenance", cmd_maintenance, RUN_SETUP | NO_PARSEOPT }, { "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE }, @@ -566,7 +566,7 @@ static struct cmd_struct commands[] = { { "merge-recursive-theirs", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT }, { "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT }, { "merge-tree", cmd_merge_tree, RUN_SETUP }, - { "mktag", cmd_mktag, RUN_SETUP | NO_PARSEOPT }, + { "mktag", cmd_mktag, RUN_SETUP }, { "mktree", cmd_mktree, RUN_SETUP }, { "multi-pack-index", cmd_multi_pack_index, RUN_SETUP }, { "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE }, -- cgit v1.2.3 From 0350954482bca6accd7b4ad072a1bdb83651b376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Fri, 19 Aug 2022 18:04:03 +0200 Subject: builtin/gc.c: let parse-options parse 'git maintenance's subcommands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'git maintenanze' parses its subcommands with a couple of if statements. parse-options has just learned to parse subcommands, so let's use that facility instead, with the benefits of shorter code, handling missing or unknown subcommands, and listing subcommands for Bash completion. This change makes 'git maintenance' consistent with other commands in that the help text shown for '-h' goes to standard output, not error, in the exit code and error message on unknown subcommand, and the error message on missing subcommand. There is a test checking these, which is now updated accordingly. Note that some of the functions implementing each subcommand don't accept any parameters, so add the (unused) 'argc', '**argv' and '*prefix' parameters to make them match the type expected by parse-options, and thus avoid casting function pointers. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git.c') diff --git a/git.c b/git.c index 09c126c33d..73ddf0f452 100644 --- a/git.c +++ b/git.c @@ -555,7 +555,7 @@ static struct cmd_struct commands[] = { { "ls-tree", cmd_ls_tree, RUN_SETUP }, { "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY }, { "mailsplit", cmd_mailsplit, NO_PARSEOPT }, - { "maintenance", cmd_maintenance, RUN_SETUP | NO_PARSEOPT }, + { "maintenance", cmd_maintenance, RUN_SETUP }, { "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE }, { "merge-base", cmd_merge_base, RUN_SETUP }, { "merge-file", cmd_merge_file, RUN_SETUP_GENTLY }, -- cgit v1.2.3 From 398c4ff582646b099eb1f3b14a525dfe5eeb5420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Fri, 19 Aug 2022 18:04:11 +0200 Subject: builtin/worktree.c: let parse-options parse subcommands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'git worktree' parses its subcommands with a long list of if statements. parse-options has just learned to parse subcommands, so let's use that facility instead, with the benefits of shorter code, handling missing or unknown subcommands, and listing subcommands for Bash completion. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git.c') diff --git a/git.c b/git.c index 73ddf0f452..f52a955410 100644 --- a/git.c +++ b/git.c @@ -627,7 +627,7 @@ static struct cmd_struct commands[] = { { "verify-tag", cmd_verify_tag, RUN_SETUP }, { "version", cmd_version }, { "whatchanged", cmd_whatchanged, RUN_SETUP }, - { "worktree", cmd_worktree, RUN_SETUP | NO_PARSEOPT }, + { "worktree", cmd_worktree, RUN_SETUP }, { "write-tree", cmd_write_tree, RUN_SETUP }, }; -- cgit v1.2.3