{"thread":{"id":"47727","subject":"[PATCH v2 00/41] Automate updating git-completion.bash a bit","startedAt":"2018-01-31T11:06:07Z","lastAt":"2018-12-12T07:50:58Z","messageCount":127,"participants":["Nguyễn Thái Ngọc Duy","Ævar Arnfjörð Bjarmason","Eric Sunshine","Duy Nguyen","Junio C Hamano","SZEDER Gábor"],"isPatch":true,"patchVersion":2,"patchTotal":41},"messages":[{"id":"337909","messageId":"20180131110547.20577-1-pclouds@gmail.com","threadId":"47727","inReplyTo":null,"subject":"[PATCH v2 00/41] Automate updating git-completion.bash a bit","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:06Z","receivedAt":"2018-01-31T11:06:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"I posted a proof of concept a while back [1]. This is the full version.\n\nThis series lets \"git\" binary help git-completion.bash to complete\n--<stuff> so that when a new option is added, we don't have to update\ngit-completion.bash manually too (people often forget it). As a side\neffect, about 180 more options are now completable.\n\nparse-options is updated to allow developers to flag certain options\nnot to be completable if they want finer control over it.  But by\ndefault, new non-hidden options are completable. Negative forms must\nbe handled manually. That's for the next step.\n\nThe number of patches is high, but changes after the first four\npatches and 33/41 are quite simple. I still need some eyeballs though\nto make sure I have not accidentally allowed completion of dangerous\noptions. Details are broken down per command in each commit message.\n\nIf people want to play with this, I have a script [2] that shows all\ncompletable options for most commands (I ignore some that are\nshell-based because I don't touch them in this series). You can then\ndo a \"diff\" to see new/old options.\n\nThere's a small conflict with 'pu' because --prune-tags is added in\ngit-completion.bash. The solution is simple and beautiful: ignore\nthose changes, --prune-tags will be completable anyway :)\n\n[1] https://public-inbox.org/git/%3C20180116103700.4505-1-pclouds@gmail.com%3E/\n[2] https://gist.github.com/pclouds/f337d4393b5cfab813909b8eea2eaa40\n\nNguyễn Thái Ngọc Duy (41):\n  parse-options: support --git-completion-helper\n  parse-options: add OPT_xxx_F() variants\n  parse-options: let OPT__FORCE take optional flags argument\n  git-completion.bash: introduce __gitcomp_builtin\n  completion: use __gitcomp_builtin in _git_add\n  completion: use __gitcomp_builtin in _git_am\n  completion: use __gitcomp_builtin in _git_apply\n  completion: use __gitcomp_builtin in _git_branch\n  completion: use __gitcomp_builtin in _git_checkout\n  completion: use __gitcomp_builtin in _git_cherry_pick\n  completion: use __gitcomp_builtin in _git_clean\n  completion: use __gitcomp_builtin in _git_clone\n  completion: use __gitcomp_builtin in _git_commit\n  completion: use __gitcomp_builtin in _git_config\n  completion: use __gitcomp_builtin in _git_describe\n  completion: use __gitcomp_builtin in _git_difftool\n  completion: use __gitcomp_builtin in _git_fetch\n  completion: use __gitcomp_builtin in _git_fsck\n  completion: use __gitcomp_builtin in _git_gc\n  completion: use __gitcomp_builtin in _git_grep\n  completion: use __gitcomp_builtin in _git_help\n  completion: use __gitcomp_builtin in _git_init\n  completion: use __gitcomp_builtin in _git_ls_files\n  completion: use __gitcomp_builtin in _git_ls_remote\n  completion: use __gitcomp_builtin in _git_merge\n  completion: use __gitcomp_builtin in _git_merge_base\n  completion: use __gitcomp_builtin in _git_mv\n  completion: use __gitcomp_builtin in _git_name_rev\n  completion: use __gitcomp_builtin in _git_notes\n  completion: use __gitcomp_builtin in _git_pull\n  completion: use __gitcomp_builtin in _git_push\n  completion: use __gitcomp_builtin in _git_remote\n  remote: force completing --mirror= instead of --mirror\n  completion: use __gitcomp_builtin in _git_replace\n  completion: use __gitcomp_builtin in _git_reset\n  completion: use __gitcomp_builtin in _git_revert\n  completion: use __gitcomp_builtin in _git_rm\n  completion: use __gitcomp_builtin in _git_show_branch\n  completion: use __gitcomp_builtin in _git_status\n  completion: use __gitcomp_builtin in _git_tag\n  completion: use __gitcomp_builtin in _git_worktree\n\n apply.c                                |   5 +-\n builtin/add.c                          |   2 +-\n builtin/am.c                           |  16 +-\n builtin/branch.c                       |   2 +-\n builtin/checkout-index.c               |   2 +-\n builtin/checkout.c                     |   7 +-\n builtin/clean.c                        |   2 +-\n builtin/fetch.c                        |   2 +-\n builtin/gc.c                           |   7 +-\n builtin/grep.c                         |  13 +-\n builtin/ls-remote.c                    |   5 +-\n builtin/mv.c                           |   3 +-\n builtin/notes.c                        |   4 +-\n builtin/pull.c                         |   2 +-\n builtin/push.c                         |   2 +-\n builtin/remote.c                       |   2 +-\n builtin/replace.c                      |   3 +-\n builtin/revert.c                       |  12 +-\n builtin/rm.c                           |   2 +-\n builtin/tag.c                          |   2 +-\n builtin/update-server-info.c           |   2 +-\n builtin/worktree.c                     |   4 +-\n contrib/completion/git-completion.bash | 276 +++++++++----------------\n parse-options.c                        |  46 +++++\n parse-options.h                        |  40 ++--\n rerere.h                               |   3 +-\n t/t9902-completion.sh                  |  12 +-\n 27 files changed, 236 insertions(+), 242 deletions(-)\n\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337910","messageId":"20180131110547.20577-2-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:07Z","receivedAt":"2018-01-31T11:06:11Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This option is designed to be used by git-completion.bash. For many\nsimple cases, what we do in there is usually\n\n    __gitcomp \"lots of completion options\"\n\nwhich has to be manually updated when a new user-visible option is\nadded. With support from parse-options, we can write\n\n    __gitcomp \"$(git command --git-completion-helper)\"\n\nand get that list directly from the parser for free. Dangerous/Unpopular\noptions could be hidden with the new \"NOCOMPLETE\" flag.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n parse-options.c | 44 ++++++++++++++++++++++++++++++++++++++++++++\n parse-options.h |  5 ++++-\n 2 files changed, 48 insertions(+), 1 deletion(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex fca7159646..29f4defdd6 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -425,6 +425,46 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,\n \tparse_options_check(options);\n }\n \n+/*\n+ * TODO: we are not completing the --no-XXX form yet because there are\n+ * many options that do not suppress it properly.\n+ */\n+static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n+\t\t\tconst struct option *opts)\n+{\n+\tfor (; opts->type != OPTION_END; opts++) {\n+\t\tconst char *suffix = \"\";\n+\n+\t\tif (!opts->long_name)\n+\t\t\tcontinue;\n+\t\tif (opts->flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE))\n+\t\t\tcontinue;\n+\n+\t\tswitch (opts->type) {\n+\t\tcase OPTION_GROUP:\n+\t\t\tcontinue;\n+\t\tcase OPTION_STRING:\n+\t\tcase OPTION_FILENAME:\n+\t\tcase OPTION_INTEGER:\n+\t\tcase OPTION_MAGNITUDE:\n+\t\tcase OPTION_CALLBACK:\n+\t\t\tif (opts->flags & PARSE_OPT_NOARG)\n+\t\t\t\tbreak;\n+\t\t\tif (opts->flags & PARSE_OPT_OPTARG)\n+\t\t\t\tbreak;\n+\t\t\tif (opts->flags & PARSE_OPT_LASTARG_DEFAULT)\n+\t\t\t\tbreak;\n+\t\t\tsuffix = \"=\";\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\t\tprintf(\" --%s%s\", opts->long_name, suffix);\n+\t}\n+\tfputc('\\n', stdout);\n+\texit(0);\n+}\n+\n static int usage_with_options_internal(struct parse_opt_ctx_t *,\n \t\t\t\t       const char * const *,\n \t\t\t\t       const struct option *, int, int);\n@@ -455,6 +495,10 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,\n \t\tif (internal_help && ctx->total == 1 && !strcmp(arg + 1, \"h\"))\n \t\t\tgoto show_usage;\n \n+\t\t/* lone --git-completion-helper is asked by git-completion.bash */\n+\t\tif (ctx->total == 1 && !strcmp(arg + 1, \"-git-completion-helper\"))\n+\t\t\treturn show_gitcomp(ctx, options);\n+\n \t\tif (arg[1] != '-') {\n \t\t\tctx->opt = arg + 1;\n \t\t\tswitch (parse_short_opt(ctx, options)) {\ndiff --git a/parse-options.h b/parse-options.h\nindex af711227ae..983de27cf0 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -38,7 +38,8 @@ enum parse_opt_option_flags {\n \tPARSE_OPT_LASTARG_DEFAULT = 16,\n \tPARSE_OPT_NODASH = 32,\n \tPARSE_OPT_LITERAL_ARGHELP = 64,\n-\tPARSE_OPT_SHELL_EVAL = 256\n+\tPARSE_OPT_SHELL_EVAL = 256,\n+\tPARSE_OPT_NOCOMPLETE = 512\n };\n \n struct option;\n@@ -89,6 +90,8 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n  *   PARSE_OPT_LITERAL_ARGHELP: says that argh shouldn't be enclosed in brackets\n  *\t\t\t\t(i.e. '<argh>') in the help message.\n  *\t\t\t\tUseful for options with multiple parameters.\n+ *   PARSE_OPT_NOCOMPLETE: by default all visible options are completable\n+ *\t\t\t   git-completion.bash. This option suppresses that.\n  *\n  * `callback`::\n  *   pointer to the callback to use for OPTION_CALLBACK or\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337911","messageId":"20180131110547.20577-3-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 02/41] parse-options: add OPT_xxx_F() variants","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:08Z","receivedAt":"2018-01-31T11:06:15Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"These macros allow us to add extra parse-options flag, the main one in\nmy mind is PARSE_OPT_NOCOMPLETE to hide certain options from\n--git-completion-helper.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n parse-options.h | 25 ++++++++++++++++---------\n 1 file changed, 16 insertions(+), 9 deletions(-)\n\ndiff --git a/parse-options.h b/parse-options.h\nindex 983de27cf0..bc41b99d3b 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -115,23 +115,30 @@ struct option {\n \tintptr_t defval;\n };\n \n+#define OPT_BIT_F(s, l, v, h, b, f) { OPTION_BIT, (s), (l), (v), NULL, (h), \\\n+\t\t\t\t      PARSE_OPT_NOARG|(f), NULL, (b) }\n+#define OPT_COUNTUP_F(s, l, v, h, f) { OPTION_COUNTUP, (s), (l), (v), NULL, \\\n+\t\t\t\t       (h), PARSE_OPT_NOARG|(f) }\n+#define OPT_SET_INT_F(s, l, v, h, i, f) { OPTION_SET_INT, (s), (l), (v), NULL, \\\n+\t\t\t\t\t  (h), PARSE_OPT_NOARG | (f), NULL, (i) }\n+#define OPT_BOOL_F(s, l, v, h, f)   OPT_SET_INT_F(s, l, v, h, 1, f)\n+#define OPT_CMDMODE_F(s, l, v, h, i, f) { OPTION_CMDMODE, (s), (l), (v), NULL, \\\n+\t\t\t\t\t  (h), PARSE_OPT_NOARG|PARSE_OPT_NONEG|(f), \\\n+\t\t\t\t\t  NULL, (i) }\n+\n #define OPT_END()                   { OPTION_END }\n #define OPT_ARGUMENT(l, h)          { OPTION_ARGUMENT, 0, (l), NULL, NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG}\n #define OPT_GROUP(h)                { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }\n-#define OPT_BIT(s, l, v, h, b)      { OPTION_BIT, (s), (l), (v), NULL, (h), \\\n-\t\t\t\t      PARSE_OPT_NOARG, NULL, (b) }\n+#define OPT_BIT(s, l, v, h, b)      OPT_BIT_F(s, l, v, h, b, 0)\n #define OPT_NEGBIT(s, l, v, h, b)   { OPTION_NEGBIT, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG, NULL, (b) }\n-#define OPT_COUNTUP(s, l, v, h)     { OPTION_COUNTUP, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG }\n-#define OPT_SET_INT(s, l, v, h, i)  { OPTION_SET_INT, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG, NULL, (i) }\n-#define OPT_BOOL(s, l, v, h)        OPT_SET_INT(s, l, v, h, 1)\n+#define OPT_COUNTUP(s, l, v, h)     OPT_COUNTUP_F(s, l, v, h, 0)\n+#define OPT_SET_INT(s, l, v, h, i)  OPT_SET_INT_F(s, l, v, h, i, 0)\n+#define OPT_BOOL(s, l, v, h)        OPT_BOOL_F(s, l, v, h, 0)\n #define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}\n-#define OPT_CMDMODE(s, l, v, h, i)  { OPTION_CMDMODE, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, (i) }\n+#define OPT_CMDMODE(s, l, v, h, i)  OPT_CMDMODE_F(s, l, v, h, i, 0)\n #define OPT_INTEGER(s, l, v, h)     { OPTION_INTEGER, (s), (l), (v), N_(\"n\"), (h) }\n #define OPT_MAGNITUDE(s, l, v, h)   { OPTION_MAGNITUDE, (s), (l), (v), \\\n \t\t\t\t      N_(\"n\"), (h), PARSE_OPT_NONEG }\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337912","messageId":"20180131110547.20577-4-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 03/41] parse-options: let OPT__FORCE take optional flags argument","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:09Z","receivedAt":"2018-01-31T11:06:24Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"--force option is most likely hidden from command line completion for\nsafety reasons. This is done by adding an extra flag\nPARSE_OPT_NOCOMPLETE. Update OPT__FORCE() to accept additional\nflags. Actual flag change comes later depending on individual\ncommands.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/add.c                | 2 +-\n builtin/branch.c             | 2 +-\n builtin/checkout-index.c     | 2 +-\n builtin/checkout.c           | 2 +-\n builtin/clean.c              | 2 +-\n builtin/fetch.c              | 2 +-\n builtin/mv.c                 | 2 +-\n builtin/notes.c              | 4 ++--\n builtin/pull.c               | 2 +-\n builtin/rm.c                 | 2 +-\n builtin/tag.c                | 2 +-\n builtin/update-server-info.c | 2 +-\n builtin/worktree.c           | 4 +++-\n parse-options.h              | 2 +-\n 14 files changed, 17 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex bf01d89e28..ac7c1c3277 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -294,7 +294,7 @@ static struct option builtin_add_options[] = {\n \tOPT_BOOL('i', \"interactive\", &add_interactive, N_(\"interactive picking\")),\n \tOPT_BOOL('p', \"patch\", &patch_interactive, N_(\"select hunks interactively\")),\n \tOPT_BOOL('e', \"edit\", &edit_interactive, N_(\"edit current diff and apply\")),\n-\tOPT__FORCE(&ignored_too, N_(\"allow adding otherwise ignored files\")),\n+\tOPT__FORCE(&ignored_too, N_(\"allow adding otherwise ignored files\"), 0),\n \tOPT_BOOL('u', \"update\", &take_worktree_changes, N_(\"update tracked files\")),\n \tOPT_BOOL(0, \"renormalize\", &add_renormalize, N_(\"renormalize EOL of tracked files (implies -u)\")),\n \tOPT_BOOL('N', \"intent-to-add\", &intent_to_add, N_(\"record only the fact that the path will be added later\")),\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 8dcc2ed058..b5b62c08ba 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -615,7 +615,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL('l', \"create-reflog\", &reflog, N_(\"create the branch's reflog\")),\n \t\tOPT_BOOL(0, \"edit-description\", &edit_description,\n \t\t\t N_(\"edit the description for the branch\")),\n-\t\tOPT__FORCE(&force, N_(\"force creation, move/rename, deletion\")),\n+\t\tOPT__FORCE(&force, N_(\"force creation, move/rename, deletion\"), 0),\n \t\tOPT_MERGED(&filter, N_(\"print only branches that are merged\")),\n \t\tOPT_NO_MERGED(&filter, N_(\"print only branches that are not merged\")),\n \t\tOPT_COLUMN(0, \"column\", &colopts, N_(\"list branches in columns\")),\ndiff --git a/builtin/checkout-index.c b/builtin/checkout-index.c\nindex b0e78b819d..a730f6a1aa 100644\n--- a/builtin/checkout-index.c\n+++ b/builtin/checkout-index.c\n@@ -157,7 +157,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n \tstruct option builtin_checkout_index_options[] = {\n \t\tOPT_BOOL('a', \"all\", &all,\n \t\t\tN_(\"check out all files in the index\")),\n-\t\tOPT__FORCE(&force, N_(\"force overwrite of existing files\")),\n+\t\tOPT__FORCE(&force, N_(\"force overwrite of existing files\"), 0),\n \t\tOPT__QUIET(&quiet,\n \t\t\tN_(\"no warning for existing files and files not in index\")),\n \t\tOPT_BOOL('n', \"no-create\", &not_new,\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex c54c78df54..2a96358eb7 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1118,7 +1118,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\t\t    2),\n \t\tOPT_SET_INT('3', \"theirs\", &opts.writeout_stage, N_(\"checkout their version for unmerged files\"),\n \t\t\t    3),\n-\t\tOPT__FORCE(&opts.force, N_(\"force checkout (throw away local modifications)\")),\n+\t\tOPT__FORCE(&opts.force, N_(\"force checkout (throw away local modifications)\"), 0),\n \t\tOPT_BOOL('m', \"merge\", &opts.merge, N_(\"perform a 3-way merge with the new branch\")),\n \t\tOPT_BOOL(0, \"overwrite-ignore\", &opts.overwrite_ignore, N_(\"update ignored files (default)\")),\n \t\tOPT_STRING(0, \"conflict\", &conflict_style, N_(\"style\"),\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 189e20628c..3c4ca9a2ff 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -909,7 +909,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__QUIET(&quiet, N_(\"do not print names of files removed\")),\n \t\tOPT__DRY_RUN(&dry_run, N_(\"dry run\")),\n-\t\tOPT__FORCE(&force, N_(\"force\")),\n+\t\tOPT__FORCE(&force, N_(\"force\"), 0),\n \t\tOPT_BOOL('i', \"interactive\", &interactive, N_(\"interactive cleaning\")),\n \t\tOPT_BOOL('d', NULL, &remove_directories,\n \t\t\t\tN_(\"remove whole directories\")),\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 7bbcd26faf..6a603174fb 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -115,7 +115,7 @@ static struct option builtin_fetch_options[] = {\n \t\t N_(\"append to .git/FETCH_HEAD instead of overwriting\")),\n \tOPT_STRING(0, \"upload-pack\", &upload_pack, N_(\"path\"),\n \t\t   N_(\"path to upload pack on remote end\")),\n-\tOPT__FORCE(&force, N_(\"force overwrite of local branch\")),\n+\tOPT__FORCE(&force, N_(\"force overwrite of local branch\"), 0),\n \tOPT_BOOL('m', \"multiple\", &multiple,\n \t\t N_(\"fetch from multiple remotes\")),\n \tOPT_SET_INT('t', \"tags\", &tags,\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex cf3684d907..b88023a733 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -122,7 +122,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \tstruct option builtin_mv_options[] = {\n \t\tOPT__VERBOSE(&verbose, N_(\"be verbose\")),\n \t\tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n-\t\tOPT__FORCE(&force, N_(\"force move/rename even if target exists\")),\n+\t\tOPT__FORCE(&force, N_(\"force move/rename even if target exists\"), 0),\n \t\tOPT_BOOL('k', NULL, &ignore_errors, N_(\"skip move/rename errors\")),\n \t\tOPT_END(),\n \t};\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 7c81761645..b52e71c73e 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -413,7 +413,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\tparse_reuse_arg},\n \t\tOPT_BOOL(0, \"allow-empty\", &allow_empty,\n \t\t\tN_(\"allow storing empty note\")),\n-\t\tOPT__FORCE(&force, N_(\"replace existing notes\")),\n+\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), 0),\n \t\tOPT_END()\n \t};\n \n@@ -484,7 +484,7 @@ static int copy(int argc, const char **argv, const char *prefix)\n \tstruct notes_tree *t;\n \tconst char *rewrite_cmd = NULL;\n \tstruct option options[] = {\n-\t\tOPT__FORCE(&force, N_(\"replace existing notes\")),\n+\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), 0),\n \t\tOPT_BOOL(0, \"stdin\", &from_stdin, N_(\"read objects from stdin\")),\n \t\tOPT_STRING(0, \"for-rewrite\", &rewrite_cmd, N_(\"command\"),\n \t\t\t   N_(\"load rewriting config for <command> (implies \"\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 511dbbe0f6..652239aae9 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -193,7 +193,7 @@ static struct option pull_options[] = {\n \tOPT_PASSTHRU(0, \"upload-pack\", &opt_upload_pack, N_(\"path\"),\n \t\tN_(\"path to upload pack on remote end\"),\n \t\t0),\n-\tOPT__FORCE(&opt_force, N_(\"force overwrite of local branch\")),\n+\tOPT__FORCE(&opt_force, N_(\"force overwrite of local branch\"), 0),\n \tOPT_PASSTHRU('t', \"tags\", &opt_tags, NULL,\n \t\tN_(\"fetch all tags and associated objects\"),\n \t\tPARSE_OPT_NOARG),\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 4a2fcca27b..6e0c7f5ac6 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -242,7 +242,7 @@ static struct option builtin_rm_options[] = {\n \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n \tOPT__QUIET(&quiet, N_(\"do not list removed files\")),\n \tOPT_BOOL( 0 , \"cached\",         &index_only, N_(\"only remove from the index\")),\n-\tOPT__FORCE(&force, N_(\"override the up-to-date check\")),\n+\tOPT__FORCE(&force, N_(\"override the up-to-date check\"), 0),\n \tOPT_BOOL('r', NULL,             &recursive,  N_(\"allow recursive removal\")),\n \tOPT_BOOL( 0 , \"ignore-unmatch\", &ignore_unmatch,\n \t\t\t\tN_(\"exit with a zero status even if nothing matched\")),\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex a7e6a5b0f2..98d3956bbe 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -391,7 +391,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"how to strip spaces and #comments from message\")),\n \t\tOPT_STRING('u', \"local-user\", &keyid, N_(\"key-id\"),\n \t\t\t\t\tN_(\"use another key to sign the tag\")),\n-\t\tOPT__FORCE(&force, N_(\"replace the tag if exists\")),\n+\t\tOPT__FORCE(&force, N_(\"replace the tag if exists\"), 0),\n \t\tOPT_BOOL(0, \"create-reflog\", &create_reflog, N_(\"create a reflog\")),\n \n \t\tOPT_GROUP(N_(\"Tag listing options\")),\ndiff --git a/builtin/update-server-info.c b/builtin/update-server-info.c\nindex 873070e517..4321a34456 100644\n--- a/builtin/update-server-info.c\n+++ b/builtin/update-server-info.c\n@@ -12,7 +12,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix)\n {\n \tint force = 0;\n \tstruct option options[] = {\n-\t\tOPT__FORCE(&force, N_(\"update the info files from scratch\")),\n+\t\tOPT__FORCE(&force, N_(\"update the info files from scratch\"), 0),\n \t\tOPT_END()\n \t};\n \ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 7cef5b120b..4d3422f62e 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -365,7 +365,9 @@ static int add(int ac, const char **av, const char *prefix)\n \tconst char *branch;\n \tconst char *opt_track = NULL;\n \tstruct option options[] = {\n-\t\tOPT__FORCE(&opts.force, N_(\"checkout <branch> even if already checked out in other worktree\")),\n+\t\tOPT__FORCE(&opts.force,\n+\t\t\t   N_(\"checkout <branch> even if already checked out in other worktree\"),\n+\t\t\t   0),\n \t\tOPT_STRING('b', NULL, &opts.new_branch, N_(\"branch\"),\n \t\t\t   N_(\"create a new branch\")),\n \t\tOPT_STRING('B', NULL, &new_branch_force, N_(\"branch\"),\ndiff --git a/parse-options.h b/parse-options.h\nindex bc41b99d3b..23c912b842 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -250,7 +250,7 @@ extern int parse_opt_passthru_argv(const struct option *, const char *, int);\n \t{ OPTION_CALLBACK, 'q', \"quiet\", (var), NULL, N_(\"be more quiet\"), \\\n \t  PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }\n #define OPT__DRY_RUN(var, h)  OPT_BOOL('n', \"dry-run\", (var), (h))\n-#define OPT__FORCE(var, h)    OPT_COUNTUP('f', \"force\",   (var), (h))\n+#define OPT__FORCE(var, h, f) OPT_COUNTUP_F('f', \"force\",   (var), (h), (f))\n #define OPT__ABBREV(var)  \\\n \t{ OPTION_CALLBACK, 0, \"abbrev\", (var), N_(\"n\"),\t\\\n \t  N_(\"use <n> digits to display SHA-1s\"),\t\\\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337913","messageId":"20180131110547.20577-5-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 04/41] git-completion.bash: introduce __gitcomp_builtin","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:10Z","receivedAt":"2018-01-31T11:06:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This is a __gitcomp wrapper that will execute\n\n    git ... --git-completion-helper\n\nto get the list of completable options. The call will be made only\nonce and cached to avoid performance issues, especially on Windows.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 24 ++++++++++++++++++++++++\n 1 file changed, 24 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3683c772c5..2d8d3434c6 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -280,6 +280,30 @@ __gitcomp ()\n \tesac\n }\n \n+# This function is equivalent to\n+#\n+#    __gitcomp \"$(git xxx --git-completion-helper) ...\"\n+#\n+# except that the value from $(git) is cached\n+__gitcomp_builtin ()\n+{\n+\t# spaces must be replaced with underscore for multi-word\n+\t# commands, e.g. \"git remote add\" becomes remote_add.\n+\tlocal cmd=\"$1\"\n+\tshift\n+\n+\tlocal var=__gitcomp_builtin_\"${cmd/-/_}\"\n+\tlocal options\n+\teval \"options=\\$$var\"\n+\n+\tif [ -z \"$options\" ]; then\n+\t\tdeclare -g \"$var=$(__git ${cmd/_/ } --git-completion-helper)\"\n+\t\teval \"options=\\$$var\"\n+\tfi\n+\n+\t__gitcomp \"$options $*\"\n+}\n+\n # Variation of __gitcomp_nl () that appends to the existing list of\n # completion candidates, COMPREPLY.\n __gitcomp_nl_append ()\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337914","messageId":"20180131110547.20577-6-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 05/41] completion: use __gitcomp_builtin in _git_add","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:11Z","receivedAt":"2018-01-31T11:06:28Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are\n\n--all\n--ignore-missing\n--ignore-removal\n--renormalize\n--verbose\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 2d8d3434c6..9aa3aa241b 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1144,10 +1144,7 @@ _git_add ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--interactive --refresh --patch --update --dry-run\n-\t\t\t--ignore-errors --intent-to-add --force --edit --chmod=\n-\t\t\t\"\n+\t\t__gitcomp_builtin add\n \t\treturn\n \tesac\n \n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337915","messageId":"20180131110547.20577-7-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 06/41] completion: use __gitcomp_builtin in _git_am","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:12Z","receivedAt":"2018-01-31T11:06:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--directory\n--exclude\n--gpg-sign\n--include\n--keep-cr\n--keep-non-patch\n--message-id\n--no-keep-cr\n--patch-format\n--quiet\n--reject\n--resolvemsg=\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/am.c                           | 16 ++++++++--------\n contrib/completion/git-completion.bash |  7 +------\n parse-options.h                        |  4 ++--\n rerere.h                               |  3 ++-\n 4 files changed, 13 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex acfe9d3c8c..d42832dc0b 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -2237,18 +2237,18 @@ int cmd_am(int argc, const char **argv, const char *prefix)\n \t\t\tPARSE_OPT_NOARG),\n \t\tOPT_STRING(0, \"resolvemsg\", &state.resolvemsg, NULL,\n \t\t\tN_(\"override error message when patch failure occurs\")),\n-\t\tOPT_CMDMODE(0, \"continue\", &resume,\n+\t\tOPT_CMDMODE_F(0, \"continue\", &resume,\n \t\t\tN_(\"continue applying patches after resolving a conflict\"),\n-\t\t\tRESUME_RESOLVED),\n-\t\tOPT_CMDMODE('r', \"resolved\", &resume,\n+\t\t\tRESUME_RESOLVED, PARSE_OPT_NOCOMPLETE),\n+\t\tOPT_CMDMODE_F('r', \"resolved\", &resume,\n \t\t\tN_(\"synonyms for --continue\"),\n-\t\t\tRESUME_RESOLVED),\n-\t\tOPT_CMDMODE(0, \"skip\", &resume,\n+\t\t\tRESUME_RESOLVED, PARSE_OPT_NOCOMPLETE),\n+\t\tOPT_CMDMODE_F(0, \"skip\", &resume,\n \t\t\tN_(\"skip the current patch\"),\n-\t\t\tRESUME_SKIP),\n-\t\tOPT_CMDMODE(0, \"abort\", &resume,\n+\t\t\tRESUME_SKIP, PARSE_OPT_NOCOMPLETE),\n+\t\tOPT_CMDMODE_F(0, \"abort\", &resume,\n \t\t\tN_(\"restore the original branch and abort the patching operation.\"),\n-\t\t\tRESUME_ABORT),\n+\t\t\tRESUME_ABORT, PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"committer-date-is-author-date\",\n \t\t\t&state.committer_date_is_author_date,\n \t\t\tN_(\"lie about committer date\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9aa3aa241b..ce53b78c81 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1110,12 +1110,7 @@ _git_am ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--3way --committer-date-is-author-date --ignore-date\n-\t\t\t--ignore-whitespace --ignore-space-change\n-\t\t\t--interactive --keep --no-utf8 --signoff --utf8\n-\t\t\t--whitespace= --scissors\n-\t\t\t\"\n+\t\t__gitcomp_builtin am \"--no-utf8\"\n \t\treturn\n \tesac\n }\ndiff --git a/parse-options.h b/parse-options.h\nindex 23c912b842..fa75df17b4 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -146,8 +146,8 @@ struct option {\n #define OPT_STRING_LIST(s, l, v, a, h) \\\n \t\t\t\t    { OPTION_CALLBACK, (s), (l), (v), (a), \\\n \t\t\t\t      (h), 0, &parse_opt_string_list }\n-#define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG, &parse_opt_tertiary }\n+#define OPT_UYN(s, l, v, h, f)      { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n+\t\t\t\t      (h), PARSE_OPT_NOARG|(f), &parse_opt_tertiary }\n #define OPT_DATE(s, l, v, h) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), N_(\"time\"),(h), 0,\t\\\n \t  parse_opt_approxidate_cb }\ndiff --git a/rerere.h b/rerere.h\nindex c2961feaaa..5e5a312e4c 100644\n--- a/rerere.h\n+++ b/rerere.h\n@@ -37,6 +37,7 @@ extern void rerere_clear(struct string_list *);\n extern void rerere_gc(struct string_list *);\n \n #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, \"rerere-autoupdate\", (v), \\\n-\tN_(\"update the index with reused conflict resolution if possible\"))\n+\tN_(\"update the index with reused conflict resolution if possible\"), \\\n+\tPARSE_OPT_NOCOMPLETE)\n \n #endif\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337916","messageId":"20180131110547.20577-8-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 07/41] completion: use __gitcomp_builtin in _git_apply","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:13Z","receivedAt":"2018-01-31T11:06:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--3way\n--allow-overlap\n--build-fake-ancestor=\n--directory\n--exclude\n--include\n\n--index-info is no longer completable but that's because it's renamed to\n--build-fake-ancestor in 26b2800768 (apply: get rid of --index-info in\nfavor of --build-fake-ancestor - 2007-09-17)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n apply.c                                | 5 +++--\n contrib/completion/git-completion.bash | 9 +--------\n 2 files changed, 4 insertions(+), 10 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 321a9fa68d..65eb37e6a4 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4943,8 +4943,9 @@ int apply_parse_options(int argc, const char **argv,\n \t\t\tN_(\"make sure the patch is applicable to the current index\")),\n \t\tOPT_BOOL(0, \"cached\", &state->cached,\n \t\t\tN_(\"apply a patch without touching the working tree\")),\n-\t\tOPT_BOOL(0, \"unsafe-paths\", &state->unsafe_paths,\n-\t\t\tN_(\"accept a patch that touches outside the working area\")),\n+\t\tOPT_BOOL_F(0, \"unsafe-paths\", &state->unsafe_paths,\n+\t\t\t   N_(\"accept a patch that touches outside the working area\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"apply\", force_apply,\n \t\t\tN_(\"also apply the patch (use with --stat/--summary/--check)\")),\n \t\tOPT_BOOL('3', \"3way\", &state->threeway,\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex ce53b78c81..6f763c524e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1123,14 +1123,7 @@ _git_apply ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--stat --numstat --summary --check --index\n-\t\t\t--cached --index-info --reverse --reject --unidiff-zero\n-\t\t\t--apply --no-add --exclude=\n-\t\t\t--ignore-whitespace --ignore-space-change\n-\t\t\t--whitespace= --inaccurate-eof --verbose\n-\t\t\t--recount --directory=\n-\t\t\t\"\n+\t\t__gitcomp_builtin apply\n \t\treturn\n \tesac\n }\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337917","messageId":"20180131110547.20577-9-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 08/41] completion: use __gitcomp_builtin in _git_branch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:14Z","receivedAt":"2018-01-31T11:06:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--all\n--create-reflog\n--format=\n--ignore-case\n--quiet\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/branch.c                       | 2 +-\n contrib/completion/git-completion.bash | 8 ++------\n 2 files changed, 3 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex b5b62c08ba..6d0cea9d4b 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -615,7 +615,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL('l', \"create-reflog\", &reflog, N_(\"create the branch's reflog\")),\n \t\tOPT_BOOL(0, \"edit-description\", &edit_description,\n \t\t\t N_(\"edit the description for the branch\")),\n-\t\tOPT__FORCE(&force, N_(\"force creation, move/rename, deletion\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"force creation, move/rename, deletion\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_MERGED(&filter, N_(\"print only branches that are merged\")),\n \t\tOPT_NO_MERGED(&filter, N_(\"print only branches that are not merged\")),\n \t\tOPT_COLUMN(0, \"column\", &colopts, N_(\"list branches in columns\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6f763c524e..4a2858f09c 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1209,12 +1209,8 @@ _git_branch ()\n \t\t__git_complete_refs --cur=\"${cur##--set-upstream-to=}\"\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--color --no-color --verbose --abbrev= --no-abbrev\n-\t\t\t--track --no-track --contains --no-contains --merged --no-merged\n-\t\t\t--set-upstream-to= --edit-description --list\n-\t\t\t--unset-upstream --delete --move --copy --remotes\n-\t\t\t--column --no-column --sort= --points-at\n+\t\t__gitcomp_builtin branch \"--no-color --no-abbrev\n+\t\t\t--no-track --no-column\n \t\t\t\"\n \t\t;;\n \t*)\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337918","messageId":"20180131110547.20577-10-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 09/41] completion: use __gitcomp_builtin in _git_checkout","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:15Z","receivedAt":"2018-01-31T11:06:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--ignore-other-worktrees\n--progress\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/checkout.c                     |  7 +++++--\n contrib/completion/git-completion.bash |  6 +-----\n t/t9902-completion.sh                  | 12 +++++++-----\n 3 files changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 2a96358eb7..a6218024a6 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1118,9 +1118,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\t\t    2),\n \t\tOPT_SET_INT('3', \"theirs\", &opts.writeout_stage, N_(\"checkout their version for unmerged files\"),\n \t\t\t    3),\n-\t\tOPT__FORCE(&opts.force, N_(\"force checkout (throw away local modifications)\"), 0),\n+\t\tOPT__FORCE(&opts.force, N_(\"force checkout (throw away local modifications)\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('m', \"merge\", &opts.merge, N_(\"perform a 3-way merge with the new branch\")),\n-\t\tOPT_BOOL(0, \"overwrite-ignore\", &opts.overwrite_ignore, N_(\"update ignored files (default)\")),\n+\t\tOPT_BOOL_F(0, \"overwrite-ignore\", &opts.overwrite_ignore,\n+\t\t\t   N_(\"update ignored files (default)\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_STRING(0, \"conflict\", &conflict_style, N_(\"style\"),\n \t\t\t   N_(\"conflict style (merge or diff3)\")),\n \t\tOPT_BOOL('p', \"patch\", &opts.patch_mode, N_(\"select hunks interactively\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 4a2858f09c..61880275ed 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1252,11 +1252,7 @@ _git_checkout ()\n \t\t__gitcomp \"diff3 merge\" \"\" \"${cur##--conflict=}\"\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--quiet --ours --theirs --track --no-track --merge\n-\t\t\t--conflict= --orphan --patch --detach --ignore-skip-worktree-bits\n-\t\t\t--recurse-submodules --no-recurse-submodules\n-\t\t\t\"\n+\t\t__gitcomp_builtin checkout \"--no-track --no-recurse-submodules\"\n \t\t;;\n \t*)\n \t\t# check if --track, --no-track, or --no-guess was specified\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex fc614dcbfa..e6485feb0a 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -1237,17 +1237,19 @@ test_expect_success 'double dash \"git\" itself' '\n test_expect_success 'double dash \"git checkout\"' '\n \ttest_completion \"git checkout --\" <<-\\EOF\n \t--quiet Z\n+\t--detach Z\n+\t--track Z\n+\t--orphan=Z\n \t--ours Z\n \t--theirs Z\n-\t--track Z\n-\t--no-track Z\n \t--merge Z\n-\t--conflict=\n-\t--orphan Z\n+\t--conflict=Z\n \t--patch Z\n-\t--detach Z\n \t--ignore-skip-worktree-bits Z\n+\t--ignore-other-worktrees Z\n \t--recurse-submodules Z\n+\t--progress Z\n+\t--no-track Z\n \t--no-recurse-submodules Z\n \tEOF\n '\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337919","messageId":"20180131110547.20577-11-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 10/41] completion: use __gitcomp_builtin in _git_cherry_pick","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:16Z","receivedAt":"2018-01-31T11:06:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--allow-empty\n--allow-empty-message\n--ff\n--gpg-sign\n--keep-redundant-commits\n--strategy-option\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 61880275ed..1b2e510cf6 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1281,7 +1281,7 @@ _git_cherry_pick ()\n \tfi\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--edit --no-commit --signoff --strategy= --mainline\"\n+\t\t__gitcomp_builtin cherry-pick\n \t\t;;\n \t*)\n \t\t__git_complete_refs\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337920","messageId":"20180131110547.20577-12-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 11/41] completion: use __gitcomp_builtin in _git_clean","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:17Z","receivedAt":"2018-01-31T11:06:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are --exclude and --interactive\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/clean.c                        | 2 +-\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 3c4ca9a2ff..fad533a0a7 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -909,7 +909,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__QUIET(&quiet, N_(\"do not print names of files removed\")),\n \t\tOPT__DRY_RUN(&dry_run, N_(\"dry run\")),\n-\t\tOPT__FORCE(&force, N_(\"force\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"force\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('i', \"interactive\", &interactive, N_(\"interactive cleaning\")),\n \t\tOPT_BOOL('d', NULL, &remove_directories,\n \t\t\t\tN_(\"remove whole directories\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1b2e510cf6..c0f6f76c3c 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1293,7 +1293,7 @@ _git_clean ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--dry-run --quiet\"\n+\t\t__gitcomp_builtin clean\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337921","messageId":"20180131110547.20577-13-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 12/41] completion: use __gitcomp_builtin in _git_clone","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:18Z","receivedAt":"2018-01-31T11:07:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--config\n--dissociate\n--ipv4\n--ipv6\n--jobs=\n--progress\n--reference-if-able\n--separate-git-dir=\n--shallow-exclude\n--shallow-since=\n--verbose\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 21 +--------------------\n 1 file changed, 1 insertion(+), 20 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex c0f6f76c3c..393f86619d 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1306,26 +1306,7 @@ _git_clone ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--local\n-\t\t\t--no-hardlinks\n-\t\t\t--shared\n-\t\t\t--reference\n-\t\t\t--quiet\n-\t\t\t--no-checkout\n-\t\t\t--bare\n-\t\t\t--mirror\n-\t\t\t--origin\n-\t\t\t--upload-pack\n-\t\t\t--template=\n-\t\t\t--depth\n-\t\t\t--single-branch\n-\t\t\t--no-tags\n-\t\t\t--branch\n-\t\t\t--recurse-submodules\n-\t\t\t--no-single-branch\n-\t\t\t--shallow-submodules\n-\t\t\t\"\n+\t\t__gitcomp_builtin clone \"--no-single-branch\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337922","messageId":"20180131110547.20577-14-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 13/41] completion: use __gitcomp_builtin in _git_commit","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:19Z","receivedAt":"2018-01-31T11:07:09Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new comletable options are:\n\n--branch\n--gpg-sign\n--long\n--no-post-rewrite\n--null\n--porcelain\n--status\n\n--allow-empty is no longer completable because it's a hidden option\nsince 4741edd549 (Remove deprecated OPTION_BOOLEAN for parsing arguments\n- 2013-08-03)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 11 +----------\n 1 file changed, 1 insertion(+), 10 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 393f86619d..8bbe94a94f 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1339,16 +1339,7 @@ _git_commit ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--all --author= --signoff --verify --no-verify\n-\t\t\t--edit --no-edit\n-\t\t\t--amend --include --only --interactive\n-\t\t\t--dry-run --reuse-message= --reedit-message=\n-\t\t\t--reset-author --file= --message= --template=\n-\t\t\t--cleanup= --untracked-files --untracked-files=\n-\t\t\t--verbose --quiet --fixup= --squash=\n-\t\t\t--patch --short --date --allow-empty\n-\t\t\t\"\n+\t\t__gitcomp_builtin commit \"--no-edit --verify\"\n \t\treturn\n \tesac\n \n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337923","messageId":"20180131110547.20577-15-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 14/41] completion: use __gitcomp_builtin in _git_config","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:20Z","receivedAt":"2018-01-31T11:07:14Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--blob=\n--bool\n--bool-or-int\n--edit\n--expiry-date\n--get-color\n--get-colorbool\n--get-urlmatch\n--includes\n--int\n--null\n--path\n--show-origin\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 9 +--------\n 1 file changed, 1 insertion(+), 8 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 8bbe94a94f..1713a583cf 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2238,14 +2238,7 @@ _git_config ()\n \tesac\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--system --global --local --file=\n-\t\t\t--list --replace-all\n-\t\t\t--get --get-all --get-regexp\n-\t\t\t--add --unset --unset-all\n-\t\t\t--remove-section --rename-section\n-\t\t\t--name-only\n-\t\t\t\"\n+\t\t__gitcomp_builtin config\n \t\treturn\n \t\t;;\n \tbranch.*.*)\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337924","messageId":"20180131110547.20577-16-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 15/41] completion: use __gitcomp_builtin in _git_describe","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:21Z","receivedAt":"2018-01-31T11:07:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1713a583cf..450d8e488e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1355,11 +1355,7 @@ _git_describe ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--all --tags --contains --abbrev= --candidates=\n-\t\t\t--exact-match --debug --long --match --always --first-parent\n-\t\t\t--exclude --dirty --broken\n-\t\t\t\"\n+\t\t__gitcomp_builtin describe\n \t\treturn\n \tesac\n \t__git_complete_refs\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337925","messageId":"20180131110547.20577-17-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 16/41] completion: use __gitcomp_builtin in _git_difftool","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:22Z","receivedAt":"2018-01-31T11:07:21Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Since we can't automatically extract diff options for completion yet,\ndifftool will take all options from $__git_diff_common_options. This\nbrings _a lot_ more completable options to difftool.\n\n--ignore-submodules is added to $__git_diff_common_options to avoid\nregression in difftool. But it's a good thing anyway even for other\ndiff commands.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 450d8e488e..255d60f12d 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1380,7 +1380,7 @@ __git_diff_common_options=\"--stat --numstat --shortstat --summary\n \t\t\t--dirstat --dirstat= --dirstat-by-file\n \t\t\t--dirstat-by-file= --cumulative\n \t\t\t--diff-algorithm=\n-\t\t\t--submodule --submodule=\n+\t\t\t--submodule --submodule= --ignore-submodules\n \"\n \n _git_diff ()\n@@ -1421,11 +1421,11 @@ _git_difftool ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"--cached --staged --pickaxe-all --pickaxe-regex\n-\t\t\t--base --ours --theirs\n-\t\t\t--no-renames --diff-filter= --find-copies-harder\n-\t\t\t--relative --ignore-submodules\n-\t\t\t--tool=\"\n+\t\t__gitcomp_builtin difftool \"$__git_diff_common_options\n+\t\t\t\t\t--base --cached --ours --theirs\n+\t\t\t\t\t--pickaxe-all --pickaxe-regex\n+\t\t\t\t\t--relative --staged\n+\t\t\t\t\t\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337926","messageId":"20180131110547.20577-18-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 17/41] completion: use __gitcomp_builtin in _git_fetch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:23Z","receivedAt":"2018-01-31T11:07:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"New completable options:\n\n--deepen=\n--ipv4\n--ipv6\n--jobs=\n--multiple\n--progress\n--refmap=\n--shallow-exclude=\n--shallow-since=\n--update-head-ok\n\nSince _git_pull() needs fetch options too, $__git_fetch_options\nremains. This variable will soon be gone after _git_pull() is updated.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 255d60f12d..316dac84e0 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1448,7 +1448,7 @@ _git_fetch ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"$__git_fetch_options\"\n+\t\t__gitcomp_builtin fetch \"--no-tags\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337927","messageId":"20180131110547.20577-19-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 18/41] completion: use __gitcomp_builtin in _git_fsck","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:24Z","receivedAt":"2018-01-31T11:07:30Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--connectivity-only\n--dangling\n--progress\n--reflogs\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 316dac84e0..4d25cfa047 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1485,10 +1485,7 @@ _git_fsck ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--tags --root --unreachable --cache --no-reflogs --full\n-\t\t\t--strict --verbose --lost-found --name-objects\n-\t\t\t\"\n+\t\t__gitcomp_builtin fsck \"--no-reflogs\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337928","messageId":"20180131110547.20577-20-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 19/41] completion: use __gitcomp_builtin in _git_gc","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:25Z","receivedAt":"2018-01-31T11:07:35Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --quiet.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/gc.c                           | 7 +++++--\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 3c5eae0edf..7fc5c16254 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -360,8 +360,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"prune unreferenced objects\"),\n \t\t\tPARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },\n \t\tOPT_BOOL(0, \"aggressive\", &aggressive, N_(\"be more thorough (increased runtime)\")),\n-\t\tOPT_BOOL(0, \"auto\", &auto_gc, N_(\"enable auto-gc mode\")),\n-\t\tOPT_BOOL(0, \"force\", &force, N_(\"force running gc even if there may be another gc running\")),\n+\t\tOPT_BOOL_F(0, \"auto\", &auto_gc, N_(\"enable auto-gc mode\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n+\t\tOPT_BOOL_F(0, \"force\", &force,\n+\t\t\t   N_(\"force running gc even if there may be another gc running\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_END()\n \t};\n \ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 4d25cfa047..f694331cfc 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1495,7 +1495,7 @@ _git_gc ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--prune --aggressive\"\n+\t\t__gitcomp_builtin gc\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337929","messageId":"20180131110547.20577-22-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 21/41] completion: use __gitcomp_builtin in _git_help","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:27Z","receivedAt":"2018-01-31T11:07:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6e78737a13..1e3cb39fde 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1569,7 +1569,7 @@ _git_help ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--all --guides --info --man --web\"\n+\t\t__gitcomp_builtin help\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337930","messageId":"20180131110547.20577-25-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 24/41] completion: use __gitcomp_builtin in _git_ls_remote","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:30Z","receivedAt":"2018-01-31T11:07:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are --quiet and --upload-pack=.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/ls-remote.c                    | 5 +++--\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex c4be98ab9e..540d56429f 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -60,8 +60,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\tOPT_BIT(0, \"refs\", &flags, N_(\"do not show peeled tags\"), REF_NORMAL),\n \t\tOPT_BOOL(0, \"get-url\", &get_url,\n \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n-\t\tOPT_SET_INT(0, \"exit-code\", &status,\n-\t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_SET_INT_F(0, \"exit-code\", &status,\n+\t\t\t      N_(\"exit with exit code 2 if no matching refs are found\"),\n+\t\t\t      2, PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"symref\", &show_symref_target,\n \t\t\t N_(\"show underlying ref in addition to the object pointed by it\")),\n \t\tOPT_END()\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e65e71760f..f1eb37fbff 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1616,7 +1616,7 @@ _git_ls_remote ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--heads --tags --refs --get-url --symref\"\n+\t\t__gitcomp_builtin ls-remote\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337931","messageId":"20180131110547.20577-26-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 25/41] completion: use __gitcomp_builtin in _git_merge","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:31Z","receivedAt":"2018-01-31T11:08:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"New completable options are:\n\n--allow-unrelated-histories\n--message=\n--overwrite-ignore\n--signoff\n--strategy-option=\n--summary\n--verify\n\nThe variable $__git_merge_options remains because _git_pull() still\nneeds it. It will soon be gone after _git_pull() is updated.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex f1eb37fbff..52baa7869f 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1754,8 +1754,13 @@ _git_merge ()\n \n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"$__git_merge_options\n-\t\t\t--rerere-autoupdate --no-rerere-autoupdate --abort --continue\"\n+\t\t__gitcomp_builtin merge \"--rerere-autoupdate\n+\t\t\t\t--no-rerere-autoupdate\n+\t\t\t\t--no-commit --no-edit --no-ff\n+\t\t\t\t--no-log --no-progress\n+\t\t\t\t--no-squash --no-stat\n+\t\t\t\t--no-verify-signatures\n+\t\t\t\t\"\n \t\treturn\n \tesac\n \t__git_complete_refs\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337932","messageId":"20180131110547.20577-27-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 26/41] completion: use __gitcomp_builtin in _git_merge_base","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:32Z","receivedAt":"2018-01-31T11:08:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completion option is --all.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 52baa7869f..1bf1728b95 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1784,7 +1784,7 @@ _git_merge_base ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--octopus --independent --is-ancestor --fork-point\"\n+\t\t__gitcomp_builtin merge-base\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337933","messageId":"20180131110547.20577-24-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 23/41] completion: use __gitcomp_builtin in _git_ls_files","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:29Z","receivedAt":"2018-01-31T11:08:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--debug\n--empty-directory\n--eol\n--recurse-submodules\n--resolve-undo\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3e0973a562..e65e71760f 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1602,13 +1602,7 @@ _git_ls_files ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--cached --deleted --modified --others --ignored\n-\t\t\t--stage --directory --no-empty-directory --unmerged\n-\t\t\t--killed --exclude= --exclude-from=\n-\t\t\t--exclude-per-directory= --exclude-standard\n-\t\t\t--error-unmatch --with-tree= --full-name\n-\t\t\t--abbrev --ignored --exclude-per-directory\n-\t\t\t\"\n+\t\t__gitcomp_builtin ls-files \"--no-empty-directory\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337934","messageId":"20180131110547.20577-28-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 27/41] completion: use __gitcomp_builtin in _git_mv","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:33Z","receivedAt":"2018-01-31T11:08:10Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --verbose.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/mv.c                           | 3 ++-\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex b88023a733..e3e308d282 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -122,7 +122,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \tstruct option builtin_mv_options[] = {\n \t\tOPT__VERBOSE(&verbose, N_(\"be verbose\")),\n \t\tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n-\t\tOPT__FORCE(&force, N_(\"force move/rename even if target exists\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"force move/rename even if target exists\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('k', NULL, &ignore_errors, N_(\"skip move/rename errors\")),\n \t\tOPT_END(),\n \t};\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1bf1728b95..0e36190a19 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1795,7 +1795,7 @@ _git_mv ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--dry-run\"\n+\t\t__gitcomp_builtin mv\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337935","messageId":"20180131110547.20577-29-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 28/41] completion: use __gitcomp_builtin in _git_name_rev","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:34Z","receivedAt":"2018-01-31T11:08:11Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--always\n--exclude\n--name-only\n--refs\n--undefined\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0e36190a19..391074a772 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1811,7 +1811,7 @@ _git_mv ()\n \n _git_name_rev ()\n {\n-\t__gitcomp \"--tags --all --stdin\"\n+\t__gitcomp_builtin name-rev\n }\n \n _git_notes ()\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337936","messageId":"20180131110547.20577-30-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 29/41] completion: use __gitcomp_builtin in _git_notes","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:35Z","receivedAt":"2018-01-31T11:08:17Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--allow-empty (notes add and notes append)\n--for-rewrite= (notes copy)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/notes.c                        |  4 ++--\n contrib/completion/git-completion.bash | 14 ++++++++------\n 2 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex b52e71c73e..6990683bd4 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -413,7 +413,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\tparse_reuse_arg},\n \t\tOPT_BOOL(0, \"allow-empty\", &allow_empty,\n \t\t\tN_(\"allow storing empty note\")),\n-\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_END()\n \t};\n \n@@ -484,7 +484,7 @@ static int copy(int argc, const char **argv, const char *prefix)\n \tstruct notes_tree *t;\n \tconst char *rewrite_cmd = NULL;\n \tstruct option options[] = {\n-\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"stdin\", &from_stdin, N_(\"read objects from stdin\")),\n \t\tOPT_STRING(0, \"for-rewrite\", &rewrite_cmd, N_(\"command\"),\n \t\t\t   N_(\"load rewriting config for <command> (implies \"\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 391074a772..14af9457af 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1821,7 +1821,7 @@ _git_notes ()\n \n \tcase \"$subcommand,$cur\" in\n \t,--*)\n-\t\t__gitcomp '--ref'\n+\t\t__gitcomp_builtin notes\n \t\t;;\n \t,*)\n \t\tcase \"$prev\" in\n@@ -1837,15 +1837,17 @@ _git_notes ()\n \tadd,--reedit-message=*|append,--reedit-message=*)\n \t\t__git_complete_refs --cur=\"${cur#*=}\"\n \t\t;;\n-\tadd,--*|append,--*)\n-\t\t__gitcomp '--file= --message= --reedit-message=\n-\t\t\t\t--reuse-message='\n+\tadd,--*)\n+\t\t__gitcomp_builtin notes_add\n+\t\t;;\n+\tappend,--*)\n+\t\t__gitcomp_builtin notes_append\n \t\t;;\n \tcopy,--*)\n-\t\t__gitcomp '--stdin'\n+\t\t__gitcomp_builtin notes_copy\n \t\t;;\n \tprune,--*)\n-\t\t__gitcomp '--dry-run --verbose'\n+\t\t__gitcomp_builtin notes_prune\n \t\t;;\n \tprune,*)\n \t\t;;\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337937","messageId":"20180131110547.20577-31-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 30/41] completion: use __gitcomp_builtin in _git_pull","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:36Z","receivedAt":"2018-01-31T11:08:18Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This is really nice. Since pull_options[] already declares all\npassthru options to 'merge' or 'fetch', a single\n\n    git pull --git-completion-helper\n\nwould provide all completable options (--no- variants are a separate\nissue). Dead shell variables can now be deleted.\n\nNew completable options are:\n\n--allow-unrelated-histories\n--ipv4\n--ipv6\n--jobs\n--refmap=\n--signoff\n--strategy-option=\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 25 +++++--------------------\n 1 file changed, 5 insertions(+), 20 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 14af9457af..225507b751 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1434,12 +1434,6 @@ _git_difftool ()\n \n __git_fetch_recurse_submodules=\"yes on-demand no\"\n \n-__git_fetch_options=\"\n-\t--quiet --verbose --append --upload-pack --force --keep --depth=\n-\t--tags --no-tags --all --prune --dry-run --recurse-submodules=\n-\t--unshallow --update-shallow\n-\"\n-\n _git_fetch ()\n {\n \tcase \"$cur\" in\n@@ -1740,14 +1734,6 @@ _git_log ()\n \t__git_complete_revlist\n }\n \n-# Common merge options shared by git-merge(1) and git-pull(1).\n-__git_merge_options=\"\n-\t--no-commit --no-stat --log --no-log --squash --strategy\n-\t--commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit\n-\t--verify-signatures --no-verify-signatures --gpg-sign\n-\t--quiet --verbose --progress --no-progress\n-\"\n-\n _git_merge ()\n {\n \t__git_complete_strategy && return\n@@ -1873,12 +1859,11 @@ _git_pull ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--rebase --no-rebase\n-\t\t\t--autostash --no-autostash\n-\t\t\t$__git_merge_options\n-\t\t\t$__git_fetch_options\n-\t\t\"\n+\t\t__gitcomp_builtin pull \"--no-autostash --no-commit --no-edit\n+\t\t\t\t\t--no-ff --no-log --no-progress --no-rebase\n+\t\t\t\t\t--no-squash --no-stat --no-tags\n+\t\t\t\t\t--no-verify-signatures\"\n+\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337938","messageId":"20180131110547.20577-32-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 31/41] completion: use __gitcomp_builtin in _git_push","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:37Z","receivedAt":"2018-01-31T11:08:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--atomic\n--exec=\n--ipv4\n--ipv6\n--no-verify\n--porcelain\n--progress\n--push-option\n--signed\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/push.c                         | 2 +-\n contrib/completion/git-completion.bash | 7 +------\n 2 files changed, 2 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/push.c b/builtin/push.c\nindex 1c28427d82..013c20d616 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -548,7 +548,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_CALLBACK, 0, \"recurse-submodules\", &recurse_submodules, \"check|on-demand|no\",\n \t\t\tN_(\"control recursive pushing of submodules\"),\n \t\t\tPARSE_OPT_OPTARG, option_parse_recurse_submodules },\n-\t\tOPT_BOOL( 0 , \"thin\", &thin, N_(\"use thin pack\")),\n+\t\tOPT_BOOL_F( 0 , \"thin\", &thin, N_(\"use thin pack\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_STRING( 0 , \"receive-pack\", &receivepack, \"receive-pack\", N_(\"receive pack program\")),\n \t\tOPT_STRING( 0 , \"exec\", &receivepack, \"receive-pack\", N_(\"receive pack program\")),\n \t\tOPT_BIT('u', \"set-upstream\", &flags, N_(\"set upstream for git pull/status\"),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 225507b751..8233dede74 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1914,12 +1914,7 @@ _git_push ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--all --mirror --tags --dry-run --force --verbose\n-\t\t\t--quiet --prune --delete --follow-tags\n-\t\t\t--receive-pack= --repo= --set-upstream\n-\t\t\t--force-with-lease --force-with-lease= --recurse-submodules=\n-\t\t\"\n+\t\t__gitcomp_builtin push\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337939","messageId":"20180131110547.20577-33-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 32/41] completion: use __gitcomp_builtin in _git_remote","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:38Z","receivedAt":"2018-01-31T11:08:30Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 8233dede74..7431ffc750 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2598,7 +2598,7 @@ _git_remote ()\n \tif [ -z \"$subcommand\" ]; then\n \t\tcase \"$cur\" in\n \t\t--*)\n-\t\t\t__gitcomp \"--verbose\"\n+\t\t\t__gitcomp_builtin remote\n \t\t\t;;\n \t\t*)\n \t\t\t__gitcomp \"$subcommands\"\n@@ -2609,33 +2609,33 @@ _git_remote ()\n \n \tcase \"$subcommand,$cur\" in\n \tadd,--*)\n-\t\t__gitcomp \"--track --master --fetch --tags --no-tags --mirror=\"\n+\t\t__gitcomp_builtin remote_add \"--no-tags\"\n \t\t;;\n \tadd,*)\n \t\t;;\n \tset-head,--*)\n-\t\t__gitcomp \"--auto --delete\"\n+\t\t__gitcomp_builtin remote_set-head\n \t\t;;\n \tset-branches,--*)\n-\t\t__gitcomp \"--add\"\n+\t\t__gitcomp_builtin remote_set-branches\n \t\t;;\n \tset-head,*|set-branches,*)\n \t\t__git_complete_remote_or_refspec\n \t\t;;\n \tupdate,--*)\n-\t\t__gitcomp \"--prune\"\n+\t\t__gitcomp_builtin remote_update\n \t\t;;\n \tupdate,*)\n \t\t__gitcomp \"$(__git_get_config_variables \"remotes\")\"\n \t\t;;\n \tset-url,--*)\n-\t\t__gitcomp \"--push --add --delete\"\n+\t\t__gitcomp_builtin remote_set-url\n \t\t;;\n \tget-url,--*)\n-\t\t__gitcomp \"--push --all\"\n+\t\t__gitcomp_builtin remote_get-url\n \t\t;;\n \tprune,--*)\n-\t\t__gitcomp \"--dry-run\"\n+\t\t__gitcomp_builtin remote_prune\n \t\t;;\n \t*)\n \t\t__gitcomp_nl \"$(__git_remotes)\"\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337940","messageId":"20180131110547.20577-23-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 22/41] completion: use __gitcomp_builtin in _git_init","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:28Z","receivedAt":"2018-01-31T11:08:32Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --separate-git-dir=.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1e3cb39fde..3e0973a562 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1592,7 +1592,7 @@ _git_init ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"--quiet --bare --template= --shared --shared=\"\n+\t\t__gitcomp_builtin init\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337941","messageId":"20180131110547.20577-34-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 33/41] remote: force completing --mirror= instead of --mirror","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:39Z","receivedAt":"2018-01-31T11:08:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"git remote --mirror\" is a special case. Technically it is possible to\nspecify --mirror without any argument. But we will get a \"dangerous,\ndeprecated!\" warning in that case.\n\nThis new parse-opt flag allows --git-completion-helper to always\ncomplete --mirror=, ignoring the dangerous use case.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/remote.c | 2 +-\n parse-options.c  | 2 ++\n parse-options.h  | 6 +++++-\n 3 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex d95bf904c3..fce9e5c0f6 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -168,7 +168,7 @@ static int add(int argc, const char **argv)\n \t\tOPT_STRING('m', \"master\", &master, N_(\"branch\"), N_(\"master branch\")),\n \t\t{ OPTION_CALLBACK, 0, \"mirror\", &mirror, N_(\"push|fetch\"),\n \t\t\tN_(\"set up remote as a mirror to push to or fetch from\"),\n-\t\t\tPARSE_OPT_OPTARG, parse_mirror_opt },\n+\t\t\tPARSE_OPT_OPTARG | PARSE_OPT_COMP_ARG, parse_mirror_opt },\n \t\tOPT_END()\n \t};\n \ndiff --git a/parse-options.c b/parse-options.c\nindex 29f4defdd6..979577ba2c 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -459,6 +459,8 @@ static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n \t\tdefault:\n \t\t\tbreak;\n \t\t}\n+\t\tif (opts->flags & PARSE_OPT_COMP_ARG)\n+\t\t\tsuffix = \"=\";\n \t\tprintf(\" --%s%s\", opts->long_name, suffix);\n \t}\n \tfputc('\\n', stdout);\ndiff --git a/parse-options.h b/parse-options.h\nindex fa75df17b4..f63151fbda 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -39,7 +39,8 @@ enum parse_opt_option_flags {\n \tPARSE_OPT_NODASH = 32,\n \tPARSE_OPT_LITERAL_ARGHELP = 64,\n \tPARSE_OPT_SHELL_EVAL = 256,\n-\tPARSE_OPT_NOCOMPLETE = 512\n+\tPARSE_OPT_NOCOMPLETE = 512,\n+\tPARSE_OPT_COMP_ARG = 1024\n };\n \n struct option;\n@@ -92,6 +93,9 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n  *\t\t\t\tUseful for options with multiple parameters.\n  *   PARSE_OPT_NOCOMPLETE: by default all visible options are completable\n  *\t\t\t   git-completion.bash. This option suppresses that.\n+ *   PARSE_OPT_COMP_ARG: this option forces to git-completion.bash to\n+ *\t\t\t complete an option as --name= not --name even if\n+ *\t\t\t the option takes optional argument.\n  *\n  * `callback`::\n  *   pointer to the callback to use for OPTION_CALLBACK or\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337942","messageId":"20180131110547.20577-35-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 34/41] completion: use __gitcomp_builtin in _git_replace","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:40Z","receivedAt":"2018-01-31T11:08:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --raw.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/replace.c                      | 3 ++-\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 10078ae371..0c1d8e1b08 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -439,7 +439,8 @@ int cmd_replace(int argc, const char **argv, const char *prefix)\n \t\tOPT_CMDMODE('d', \"delete\", &cmdmode, N_(\"delete replace refs\"), MODE_DELETE),\n \t\tOPT_CMDMODE('e', \"edit\", &cmdmode, N_(\"edit existing object\"), MODE_EDIT),\n \t\tOPT_CMDMODE('g', \"graft\", &cmdmode, N_(\"change a commit's parents\"), MODE_GRAFT),\n-\t\tOPT_BOOL('f', \"force\", &force, N_(\"replace the ref if it exists\")),\n+\t\tOPT_BOOL_F('f', \"force\", &force, N_(\"replace the ref if it exists\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"raw\", &raw, N_(\"do not pretty-print contents for --edit\")),\n \t\tOPT_STRING(0, \"format\", &format, N_(\"format\"), N_(\"use this format\")),\n \t\tOPT_END()\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7431ffc750..2f3f11451d 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2647,7 +2647,7 @@ _git_replace ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--edit --graft --format= --list --delete\"\n+\t\t__gitcomp_builtin replace\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337943","messageId":"20180131110547.20577-36-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 35/41] completion: use __gitcomp_builtin in _git_reset","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:41Z","receivedAt":"2018-01-31T11:08:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--intent-to-add\n--quiet\n--recurse-submodules\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 2f3f11451d..a830c9c854 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2671,7 +2671,7 @@ _git_reset ()\n \n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--merge --mixed --hard --soft --patch --keep\"\n+\t\t__gitcomp_builtin reset\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337944","messageId":"20180131110547.20577-37-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 36/41] completion: use __gitcomp_builtin in _git_revert","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:42Z","receivedAt":"2018-01-31T11:08:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --gpg-sign\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/revert.c                       | 12 +++++++++---\n contrib/completion/git-completion.bash |  5 +----\n 2 files changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex b9d927eb09..c8e045911b 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -96,9 +96,15 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)\n \tconst char *me = action_name(opts);\n \tint cmd = 0;\n \tstruct option base_options[] = {\n-\t\tOPT_CMDMODE(0, \"quit\", &cmd, N_(\"end revert or cherry-pick sequence\"), 'q'),\n-\t\tOPT_CMDMODE(0, \"continue\", &cmd, N_(\"resume revert or cherry-pick sequence\"), 'c'),\n-\t\tOPT_CMDMODE(0, \"abort\", &cmd, N_(\"cancel revert or cherry-pick sequence\"), 'a'),\n+\t\tOPT_CMDMODE_F(0, \"quit\", &cmd,\n+\t\t\t      N_(\"end revert or cherry-pick sequence\"),\n+\t\t\t      'q', PARSE_OPT_NOCOMPLETE),\n+\t\tOPT_CMDMODE_F(0, \"continue\", &cmd,\n+\t\t\t      N_(\"resume revert or cherry-pick sequence\"),\n+\t\t\t      'c', PARSE_OPT_NOCOMPLETE),\n+\t\tOPT_CMDMODE_F(0, \"abort\", &cmd,\n+\t\t\t      N_(\"cancel revert or cherry-pick sequence\"),\n+\t\t\t      'a', PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('n', \"no-commit\", &opts->no_commit, N_(\"don't automatically commit\")),\n \t\tOPT_BOOL('e', \"edit\", &opts->edit, N_(\"edit the commit message\")),\n \t\tOPT_NOOP_NOARG('r', NULL),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex a830c9c854..d6215c494e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2687,10 +2687,7 @@ _git_revert ()\n \tfi\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--edit --mainline --no-edit --no-commit --signoff\n-\t\t\t--strategy= --strategy-option=\n-\t\t\t\"\n+\t\t__gitcomp_builtin revert \"--no-edit\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337945","messageId":"20180131110547.20577-38-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 37/41] completion: use __gitcomp_builtin in _git_rm","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:43Z","receivedAt":"2018-01-31T11:08:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/rm.c                           | 2 +-\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 6e0c7f5ac6..a818efe230 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -242,7 +242,7 @@ static struct option builtin_rm_options[] = {\n \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n \tOPT__QUIET(&quiet, N_(\"do not list removed files\")),\n \tOPT_BOOL( 0 , \"cached\",         &index_only, N_(\"only remove from the index\")),\n-\tOPT__FORCE(&force, N_(\"override the up-to-date check\"), 0),\n+\tOPT__FORCE(&force, N_(\"override the up-to-date check\"), PARSE_OPT_NOCOMPLETE),\n \tOPT_BOOL('r', NULL,             &recursive,  N_(\"allow recursive removal\")),\n \tOPT_BOOL( 0 , \"ignore-unmatch\", &ignore_unmatch,\n \t\t\t\tN_(\"exit with a zero status even if nothing matched\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex d6215c494e..e5a9f7f9b4 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2698,7 +2698,7 @@ _git_rm ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--cached --dry-run --ignore-unmatch --quiet\"\n+\t\t__gitcomp_builtin rm\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337946","messageId":"20180131110547.20577-39-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 38/41] completion: use __gitcomp_builtin in _git_show_branch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:44Z","receivedAt":"2018-01-31T11:08:54Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e5a9f7f9b4..3722c6444a 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2756,12 +2756,7 @@ _git_show_branch ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--all --remotes --topo-order --date-order --current --more=\n-\t\t\t--list --independent --merge-base --no-name\n-\t\t\t--color --no-color\n-\t\t\t--sha1-name --sparse --topics --reflog\n-\t\t\t\"\n+\t\t__gitcomp_builtin show-branch \"--no-color\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337947","messageId":"20180131110547.20577-40-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 39/41] completion: use __gitcomp_builtin in _git_status","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:45Z","receivedAt":"2018-01-31T11:09:01Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are --null and --show-stash.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3722c6444a..ba9438e437 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2052,11 +2052,7 @@ _git_status ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--short --branch --porcelain --long --verbose\n-\t\t\t--untracked-files= --ignore-submodules= --ignored\n-\t\t\t--column= --no-column\n-\t\t\t\"\n+\t\t__gitcomp_builtin status \"--no-column\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337948","messageId":"20180131110547.20577-41-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 40/41] completion: use __gitcomp_builtin in _git_tag","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:46Z","receivedAt":"2018-01-31T11:09:12Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--color\n--format=\n--ignore-case\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex ba9438e437..179ddd8c44 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2985,11 +2985,7 @@ _git_tag ()\n \n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--list --delete --verify --annotate --message --file\n-\t\t\t--sign --cleanup --local-user --force --column --sort=\n-\t\t\t--contains --no-contains --points-at --merged --no-merged --create-reflog\n-\t\t\t\"\n+\t\t__gitcomp_builtin tag\n \t\t;;\n \tesac\n }\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337949","messageId":"20180131110547.20577-42-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 41/41] completion: use __gitcomp_builtin in _git_worktree","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:47Z","receivedAt":"2018-01-31T11:09:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options for \"worktree add\" are:\n\n--checkout\n--guess-remote\n--lock\n--track\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/worktree.c                     | 2 +-\n contrib/completion/git-completion.bash | 8 ++++----\n 2 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 4d3422f62e..76dc6b8cb5 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -367,7 +367,7 @@ static int add(int ac, const char **av, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__FORCE(&opts.force,\n \t\t\t   N_(\"checkout <branch> even if already checked out in other worktree\"),\n-\t\t\t   0),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_STRING('b', NULL, &opts.new_branch, N_(\"branch\"),\n \t\t\t   N_(\"create a new branch\")),\n \t\tOPT_STRING('B', NULL, &new_branch_force, N_(\"branch\"),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 179ddd8c44..cfd24c5764 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -3004,16 +3004,16 @@ _git_worktree ()\n \telse\n \t\tcase \"$subcommand,$cur\" in\n \t\tadd,--*)\n-\t\t\t__gitcomp \"--detach\"\n+\t\t\t__gitcomp_builtin worktree_add\n \t\t\t;;\n \t\tlist,--*)\n-\t\t\t__gitcomp \"--porcelain\"\n+\t\t\t__gitcomp_builtin worktree_list\n \t\t\t;;\n \t\tlock,--*)\n-\t\t\t__gitcomp \"--reason\"\n+\t\t\t__gitcomp_builtin worktree_lock\n \t\t\t;;\n \t\tprune,--*)\n-\t\t\t__gitcomp \"--dry-run --expire --verbose\"\n+\t\t\t__gitcomp_builtin worktree_prune\n \t\t\t;;\n \t\t*)\n \t\t\t;;\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337950","messageId":"20180131110547.20577-21-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v2 20/41] completion: use __gitcomp_builtin in _git_grep","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-31T11:05:26Z","receivedAt":"2018-01-31T11:09:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--after-context=\n--before-context=\n--color\n--context\n--exclude-standard\n--quiet\n--recurse-submodules\n--textconv\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/grep.c                         | 13 ++++++++-----\n contrib/completion/git-completion.bash | 16 +---------------\n 2 files changed, 9 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ca4ac80d8..496f33336e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -832,8 +832,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL('L', \"files-without-match\",\n \t\t\t&opt.unmatch_name_only,\n \t\t\tN_(\"show only the names of files without match\")),\n-\t\tOPT_BOOL('z', \"null\", &opt.null_following_name,\n-\t\t\tN_(\"print NUL after filenames\")),\n+\t\tOPT_BOOL_F('z', \"null\", &opt.null_following_name,\n+\t\t\t   N_(\"print NUL after filenames\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('c', \"count\", &opt.count,\n \t\t\tN_(\"show the number of matches instead of matching lines\")),\n \t\tOPT__COLOR(&opt.color, N_(\"highlight matches\")),\n@@ -884,9 +885,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_GROUP(\"\"),\n \t\t{ OPTION_STRING, 'O', \"open-files-in-pager\", &show_in_pager,\n \t\t\tN_(\"pager\"), N_(\"show matching files in the pager\"),\n-\t\t\tPARSE_OPT_OPTARG, NULL, (intptr_t)default_pager },\n-\t\tOPT_BOOL(0, \"ext-grep\", &external_grep_allowed__ignored,\n-\t\t\t N_(\"allow calling of grep(1) (ignored by this build)\")),\n+\t\t\tPARSE_OPT_OPTARG | PARSE_OPT_NOCOMPLETE,\n+\t\t\tNULL, (intptr_t)default_pager },\n+\t\tOPT_BOOL_F(0, \"ext-grep\", &external_grep_allowed__ignored,\n+\t\t\t   N_(\"allow calling of grep(1) (ignored by this build)\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_END()\n \t};\n \ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex f694331cfc..6e78737a13 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1551,21 +1551,7 @@ _git_grep ()\n \n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--cached\n-\t\t\t--text --ignore-case --word-regexp --invert-match\n-\t\t\t--full-name --line-number\n-\t\t\t--extended-regexp --basic-regexp --fixed-strings\n-\t\t\t--perl-regexp\n-\t\t\t--threads\n-\t\t\t--files-with-matches --name-only\n-\t\t\t--files-without-match\n-\t\t\t--max-depth\n-\t\t\t--count\n-\t\t\t--and --or --not --all-match\n-\t\t\t--break --heading --show-function --function-context\n-\t\t\t--untracked --no-index\n-\t\t\t\"\n+\t\t__gitcomp_builtin grep\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.205.g271f633410\n\n"},{"id":"337960","messageId":"87po5qm5sb.fsf@evledraar.gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"Re: [PATCH v2 00/41] Automate updating git-completion.bash a bit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-31T15:01:08Z","receivedAt":"2018-01-31T15:01:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Jan 31 2018, Nguyễn Thái Ngọc Duy jotted:\n\n> I posted a proof of concept a while back [1]. This is the full version.\n>\n> This series lets \"git\" binary help git-completion.bash to complete\n> --<stuff> so that when a new option is added, we don't have to update\n> git-completion.bash manually too (people often forget it). As a side\n> effect, about 180 more options are now completable.\n>\n> parse-options is updated to allow developers to flag certain options\n> not to be completable if they want finer control over it.  But by\n> default, new non-hidden options are completable. Negative forms must\n> be handled manually. That's for the next step.\n>\n> The number of patches is high, but changes after the first four\n> patches and 33/41 are quite simple. I still need some eyeballs though\n> to make sure I have not accidentally allowed completion of dangerous\n> options. Details are broken down per command in each commit message.\n>\n> If people want to play with this, I have a script [2] that shows all\n> completable options for most commands (I ignore some that are\n> shell-based because I don't touch them in this series). You can then\n> do a \"diff\" to see new/old options.\n\nThanks, looks great to me, especially caching the result of the\ncompletion.\n\n> There's a small conflict with 'pu' because --prune-tags is added in\n> git-completion.bash. The solution is simple and beautiful: ignore\n> those changes, --prune-tags will be completable anyway :)\n\nYay! Also another good argument for this series, it took me until v3\nuntil I noticed I'd forgotten the bash completion:\nhttps://public-inbox.org/git/20180123221326.28495-1-avarab@gmail.com/\n\n> parse-options: add OPT_xxx_F() variants\n\nNot directly related to this series, but my own\nhttps://public-inbox.org/git/20170324231013.23346-1-avarab@gmail.com/\nwhich I've been meaning to clean up and re-submit also added some new\nmacros to this file.\n\nI've been wondering what a good solution is to avoid a combinatorial\nexplosion explosion of these macros in the longer term, but haven't come\nup with anthing.\n"},{"id":"337973","messageId":"CAPig+cQ8WAk3FeXSza4_Zm+LQitnndTBCwsYWpbSNuXzfFD5rw@mail.gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-2-pclouds@gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-01-31T20:22:59Z","receivedAt":"2018-01-31T20:23:21Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jan 31, 2018 at 6:05 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> This option is designed to be used by git-completion.bash. For many\n> simple cases, what we do in there is usually\n>\n>     __gitcomp \"lots of completion options\"\n>\n> which has to be manually updated when a new user-visible option is\n> added. With support from parse-options, we can write\n>\n>     __gitcomp \"$(git command --git-completion-helper)\"\n>\n> and get that list directly from the parser for free. Dangerous/Unpopular\n> options could be hidden with the new \"NOCOMPLETE\" flag.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n> diff --git a/parse-options.h b/parse-options.h\n> @@ -89,6 +90,8 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n> + *   PARSE_OPT_NOCOMPLETE: by default all visible options are completable\n> + *                        git-completion.bash. This option suppresses that.\n\ns/git-/by &/\n"},{"id":"337974","messageId":"CAPig+cSq9T=r6uEqwxtaCtD1RQkeiavF7M24AvM=fo4nYhrhag@mail.gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-14-pclouds@gmail.com","subject":"Re: [PATCH v2 13/41] completion: use __gitcomp_builtin in _git_commit","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-01-31T20:42:25Z","receivedAt":"2018-01-31T20:42:31Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jan 31, 2018 at 6:05 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> The new comletable options are:\n\ns/comletable/completable/\n\n> --branch\n> --gpg-sign\n> --long\n> --no-post-rewrite\n> --null\n> --porcelain\n> --status\n>\n> --allow-empty is no longer completable because it's a hidden option\n> since 4741edd549 (Remove deprecated OPTION_BOOLEAN for parsing arguments\n> - 2013-08-03)\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n"},{"id":"337975","messageId":"CAPig+cT5GkhFJ9XFDSirGjfoji4qUCM8LA6abdRsaT=g3prznQ@mail.gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-2-pclouds@gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-01-31T21:04:40Z","receivedAt":"2018-01-31T21:05:01Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jan 31, 2018 at 6:05 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> This option is designed to be used by git-completion.bash. For many\n> simple cases, what we do in there is usually\n>\n>     __gitcomp \"lots of completion options\"\n>\n> which has to be manually updated when a new user-visible option is\n> added. With support from parse-options, we can write\n>\n>     __gitcomp \"$(git command --git-completion-helper)\"\n>\n> and get that list directly from the parser for free. Dangerous/Unpopular\n> options could be hidden with the new \"NOCOMPLETE\" flag.\n\nI wonder if this option should be named DANGEROUS rather than\nNOCOMPLETE to better reflect its intention. The reason I ask is that\nit is easy to imagine git-completion.bash some day growing a new\nconfiguration option to allow people to complete these \"dangerous\"\noptions, as well, rather than us imposing, with no escape hatch, our\nidea of what should and should not complete.\n\nIt's not uncommon for \"bug reports\" to be sent to the list stating\nthat such-and-such option (say, --force) does not autocomplete. Our\nstock answer is \"oh, that's a dangerous option, so you'll have to type\nit manually\". If git-completion.bash gains new configuration to allow\ndangerous options, then our answer can become \"oh, that's a dangerous\noption, if you really want it to complete, then enable\nGIT_COMPLETION_DANGEROUS\" (or whatever).\n"},{"id":"337986","messageId":"CACsJy8B0D=u5fGA2QWuG6QG-fmReg=GayC54+pSFjXHDrnKh3w@mail.gmail.com","threadId":"47727","inReplyTo":"CAPig+cT5GkhFJ9XFDSirGjfoji4qUCM8LA6abdRsaT=g3prznQ@mail.gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-01T00:05:44Z","receivedAt":"2018-02-01T00:06:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Feb 1, 2018 at 4:04 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Wed, Jan 31, 2018 at 6:05 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>> This option is designed to be used by git-completion.bash. For many\n>> simple cases, what we do in there is usually\n>>\n>>     __gitcomp \"lots of completion options\"\n>>\n>> which has to be manually updated when a new user-visible option is\n>> added. With support from parse-options, we can write\n>>\n>>     __gitcomp \"$(git command --git-completion-helper)\"\n>>\n>> and get that list directly from the parser for free. Dangerous/Unpopular\n>> options could be hidden with the new \"NOCOMPLETE\" flag.\n>\n> I wonder if this option should be named DANGEROUS rather than\n> NOCOMPLETE to better reflect its intention.\n\nIt's not only for dangerous options (I forgot to mention this in the\ncommit message, I will in v3). The --continue|--abort|--skip should\nonly show up when you are in a middle of rebase/am/cherry-pick.\ngit-completion.bash handles this case separately and only put them in\nthe completion list  when appropriate. --git-completion-helper must\nnot include these or the trick done by git-completion.bash becomes\nuseless.\n\n> The reason I ask is that\n> it is easy to imagine git-completion.bash some day growing a new\n> configuration option to allow people to complete these \"dangerous\"\n> options, as well, rather than us imposing, with no escape hatch, our\n> idea of what should and should not complete.\n>\n> It's not uncommon for \"bug reports\" to be sent to the list stating\n> that such-and-such option (say, --force) does not autocomplete. Our\n> stock answer is \"oh, that's a dangerous option, so you'll have to type\n> it manually\". If git-completion.bash gains new configuration to allow\n> dangerous options, then our answer can become \"oh, that's a dangerous\n> option, if you really want it to complete, then enable\n> GIT_COMPLETION_DANGEROUS\" (or whatever).\n\nInteresting. So we now have two classes of \"no complete\". One can't be\nconfigurable (--continue|--abort|--skip) and one can. I'll use two\nseparate flags for these, though I'm not adding the configuration\noption right now. It's easy to do and can way until someone actually\nasks for it.\n-- \nDuy\n"},{"id":"338008","messageId":"CAPig+cSLYDJaxCyAH_zK0cat2-60OZGWGy_ZLHwitHfZ7oA78w@mail.gmail.com","threadId":"47727","inReplyTo":"CACsJy8B0D=u5fGA2QWuG6QG-fmReg=GayC54+pSFjXHDrnKh3w@mail.gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-02-01T09:54:02Z","receivedAt":"2018-02-01T09:54:08Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jan 31, 2018 at 7:05 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Thu, Feb 1, 2018 at 4:04 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> On Wed, Jan 31, 2018 at 6:05 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>>> Dangerous/Unpopular\n>>> options could be hidden with the new \"NOCOMPLETE\" flag.\n>>\n>> I wonder if this option should be named DANGEROUS rather than\n>> NOCOMPLETE to better reflect its intention.\n>\n> It's not only for dangerous options (I forgot to mention this in the\n> commit message, I will in v3). The --continue|--abort|--skip should\n> only show up when you are in a middle of rebase/am/cherry-pick.\n> git-completion.bash handles this case separately and only put them in\n> the completion list  when appropriate. --git-completion-helper must\n> not include these or the trick done by git-completion.bash becomes\n> useless.\n>\n> Interesting. So we now have two classes of \"no complete\". One can't be\n> configurable (--continue|--abort|--skip) and one can. I'll use two\n> separate flags for these, though I'm not adding the configuration\n> option right now.\n\nI don't see that as convincing argument for two classes of \"no\ncomplete\". Since git-completion.bash already special-cases\nrebase/am/cherry-pick for --continue|--abort|--skip, it is not far\nfetched that that special-case treatment can be extended slightly to\nalso filter out those three options from the list returned by\n--git-completion-helper.\n\nSo, if that special case is handled entirely by the completion script,\nthen that leaves only the \"dangerous\" options, which requires only a\nsingle flag.\n"},{"id":"338015","messageId":"CACsJy8D5iGVDHKoMeQjm+Seea_pTixsb8Xq6D1w17Y9M42iAPw@mail.gmail.com","threadId":"47727","inReplyTo":"CAPig+cSLYDJaxCyAH_zK0cat2-60OZGWGy_ZLHwitHfZ7oA78w@mail.gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-01T10:21:38Z","receivedAt":"2018-02-01T10:22:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Feb 1, 2018 at 4:54 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Wed, Jan 31, 2018 at 7:05 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n>> On Thu, Feb 1, 2018 at 4:04 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>> On Wed, Jan 31, 2018 at 6:05 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>>>> Dangerous/Unpopular\n>>>> options could be hidden with the new \"NOCOMPLETE\" flag.\n>>>\n>>> I wonder if this option should be named DANGEROUS rather than\n>>> NOCOMPLETE to better reflect its intention.\n>>\n>> It's not only for dangerous options (I forgot to mention this in the\n>> commit message, I will in v3). The --continue|--abort|--skip should\n>> only show up when you are in a middle of rebase/am/cherry-pick.\n>> git-completion.bash handles this case separately and only put them in\n>> the completion list  when appropriate. --git-completion-helper must\n>> not include these or the trick done by git-completion.bash becomes\n>> useless.\n>>\n>> Interesting. So we now have two classes of \"no complete\". One can't be\n>> configurable (--continue|--abort|--skip) and one can. I'll use two\n>> separate flags for these, though I'm not adding the configuration\n>> option right now.\n>\n> I don't see that as convincing argument for two classes of \"no\n> complete\". Since git-completion.bash already special-cases\n> rebase/am/cherry-pick for --continue|--abort|--skip, it is not far\n> fetched that that special-case treatment can be extended slightly to\n> also filter out those three options from the list returned by\n> --git-completion-helper.\n\nI agree that is possible, but it's a bit tricky to do the filtering\nright in bash (all options are sent back as one line instead of one\nper line, which is easier to process by command line tools).\n\nOn top of  that, I think we want git-completion.bash to be fast, the\nmore commands we execute there, the unhappier Windows users are. It is\ntoo possible to do this kind of filtering just once, before caching.\nIt does not fit well to how I designed __gitcomp_builtin so I need to\nsit back and see how to sort that out.\n\nLong term though, I think we would want more and more completion logic\nbuilt in. One of those things I have in mind is to let\n--git-completion-helper (or some other new option) to provide\ncompletion for possible option values (e.g. true/false, values for\n\"git merge --strategy=\", \"git status --untrack-files=\"....). That may\nalso include completion of --continue|--abort|.. in C code, something\nlike this roughly\n\n# separate command blocks because we still need to cache them in shell\nif [ -f .git/rebase-apply ]; then\n    __gitcomp $(git $cmd --git-completion-helper=in-progress)\nelse\n    __gitcomp $(git $cmd --git-completion-helper)\nfi\n\nwhich means eventually we have to flag these options differently.\n\nHaving said all that, these are the things I imagine we _might_ do. I\nhave not really thought it through and nor do I have a clear plan\nforward at this point, so they may end up being just rubbish thoughts.\n\n> So, if that special case is handled entirely by the completion script,\n> then that leaves only the \"dangerous\" options, which requires only a\n> single flag.\n-- \nDuy\n"},{"id":"338039","messageId":"CAPig+cRWzvcDUjw7CR78nZ0cbE-mPkB1a4UZqiChR0NUKSZOVw@mail.gmail.com","threadId":"47727","inReplyTo":"CACsJy8D5iGVDHKoMeQjm+Seea_pTixsb8Xq6D1w17Y9M42iAPw@mail.gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-02-01T19:16:46Z","receivedAt":"2018-02-01T19:16:51Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Feb 1, 2018 at 5:21 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Thu, Feb 1, 2018 at 4:54 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> I don't see that as convincing argument for two classes of \"no\n>> complete\". Since git-completion.bash already special-cases\n>> rebase/am/cherry-pick for --continue|--abort|--skip, it is not far\n>> fetched that that special-case treatment can be extended slightly to\n>> also filter out those three options from the list returned by\n>> --git-completion-helper.\n>\n> I agree that is possible, but it's a bit tricky to do the filtering\n> right in bash (all options are sent back as one line instead of one\n> per line, which is easier to process by command line tools).\n\nPerhaps I'm missing something, but wouldn't filtering out those\noptions directly in Bash require only this?\n\n    % x='--foo --bar --snoo'\n    % echo ${x/--bar}\n    --foo --snoo\n\n> On top of  that, I think we want git-completion.bash to be fast, the\n> more commands we execute there, the unhappier Windows users are. It is\n> too possible to do this kind of filtering just once, before caching.\n> It does not fit well to how I designed __gitcomp_builtin so I need to\n> sit back and see how to sort that out.\n\nThe filtering as illustrated above using builtin Bash functionality\nseems unlikely to be a source of noticeable slow down on Windows.\n\nAnd, if you're concerned about it not fitting the design of\n__gitcomp_builtin, it's almost certainly cheap enough to do the\nfiltering each time its needed rather than worrying about caching the\nfiltered list. (It's hard to imagine anyone noticing a slow down of\nthree extra ${x/} substitutions.)\n"},{"id":"338183","messageId":"20180205095608.GA12370@ash","threadId":"47727","inReplyTo":"CAPig+cRWzvcDUjw7CR78nZ0cbE-mPkB1a4UZqiChR0NUKSZOVw@mail.gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-05T09:56:08Z","receivedAt":"2018-02-05T09:56:20Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Feb 01, 2018 at 02:16:46PM -0500, Eric Sunshine wrote:\n> On Thu, Feb 1, 2018 at 5:21 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n> > On Thu, Feb 1, 2018 at 4:54 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> >> I don't see that as convincing argument for two classes of \"no\n> >> complete\". Since git-completion.bash already special-cases\n> >> rebase/am/cherry-pick for --continue|--abort|--skip, it is not far\n> >> fetched that that special-case treatment can be extended slightly to\n> >> also filter out those three options from the list returned by\n> >> --git-completion-helper.\n> >\n> > I agree that is possible, but it's a bit tricky to do the filtering\n> > right in bash (all options are sent back as one line instead of one\n> > per line, which is easier to process by command line tools).\n> \n> Perhaps I'm missing something, but wouldn't filtering out those\n> options directly in Bash require only this?\n> \n>     % x='--foo --bar --snoo'\n>     % echo ${x/--bar}\n>     --foo --snoo\n\nOK how about some thing like this fixup patch? __gitcomp_builtin now\nallows to add extra options as well as remove some.\n\n-- 8< --\nSubject: [PATCH] fixup! git-completion.bash: introduce __gitcomp_builtin\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 17 ++++++++++++-----\n 1 file changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex cfd24c5764..ecd5896064 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -284,24 +284,31 @@ __gitcomp ()\n #\n #    __gitcomp \"$(git xxx --git-completion-helper) ...\"\n #\n-# except that the value from $(git) is cached\n+# except that the output is cached. Accept 1-3 arguments:\n+# 1: the git command to execute, this is also the cache key\n+# 2: extra options to be added on top (e.g. negative forms)\n+# 3: options to be excluded\n __gitcomp_builtin ()\n {\n \t# spaces must be replaced with underscore for multi-word\n \t# commands, e.g. \"git remote add\" becomes remote_add.\n \tlocal cmd=\"$1\"\n-\tshift\n+\tlocal incl=\"$2\"\n+\tlocal excl=\"$3\"\n \n \tlocal var=__gitcomp_builtin_\"${cmd/-/_}\"\n \tlocal options\n \teval \"options=\\$$var\"\n \n \tif [ -z \"$options\" ]; then\n-\t\tdeclare -g \"$var=$(__git ${cmd/_/ } --git-completion-helper)\"\n-\t\teval \"options=\\$$var\"\n+\t\toptions=\"$(__git ${cmd/_/ } --git-completion-helper) $incl \"\n+\t\tfor i in $excl; do\n+\t\t\toptions=\"${options/$i /}\"\n+\t\tdone\n+\t\teval \"$var=\\\"$options\\\"\"\n \tfi\n \n-\t__gitcomp \"$options $*\"\n+\t__gitcomp \"$options\"\n }\n \n # Variation of __gitcomp_nl () that appends to the existing list of\n-- \n2.16.1.207.gedba492059\n\n-- 8< --\n\nUsage would be something like this\n\n-- 8< --\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex ecd5896064..049bfc3320 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1103,12 +1103,13 @@ __git_count_arguments ()\n }\n \n __git_whitespacelist=\"nowarn warn error error-all fix\"\n+__git_am_inprogress_options=\"--skip --continue --resolved --abort\"\n \n _git_am ()\n {\n \t__git_find_repo_path\n \tif [ -d \"$__git_repo_path\"/rebase-apply ]; then\n-\t\t__gitcomp \"--skip --continue --resolved --abort\"\n+\t\t__gitcomp \"$__git_am_inprogress_options\"\n \t\treturn\n \tfi\n \tcase \"$cur\" in\n@@ -1117,7 +1118,8 @@ _git_am ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp_builtin am \"--no-utf8\"\n+\t\t__gitcomp_builtin am \"--no-utf8\" \\\n+\t\t\t\"$__git_am_inprogress_options\"\n \t\treturn\n \tesac\n }\n-- 8< --\n\nI think I'm keeping the flag name PARSE_OPT_NOCOMPLETE for now\nthough. There are a few options that don't fit in \"dangerous\"\ncategory, e.g.\n\n- \"gc --auto\" is hidden because it does not make sense to type it\n  directly. Same story for \"push --thin\".\n\n- \"grep --ext-grep\" is no-op\n\n- --null, --exit-code and others are for scripting and not that often\n  typed.\n--\nDuy\n"},{"id":"338185","messageId":"87y3k7lnnn.fsf@evledraar.gmail.com","threadId":"47727","inReplyTo":"CAPig+cT5GkhFJ9XFDSirGjfoji4qUCM8LA6abdRsaT=g3prznQ@mail.gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-02-05T10:46:20Z","receivedAt":"2018-02-05T10:46:28Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Jan 31 2018, Eric Sunshine jotted:\n\n> On Wed, Jan 31, 2018 at 6:05 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>> This option is designed to be used by git-completion.bash. For many\n>> simple cases, what we do in there is usually\n>>\n>>     __gitcomp \"lots of completion options\"\n>>\n>> which has to be manually updated when a new user-visible option is\n>> added. With support from parse-options, we can write\n>>\n>>     __gitcomp \"$(git command --git-completion-helper)\"\n>>\n>> and get that list directly from the parser for free. Dangerous/Unpopular\n>> options could be hidden with the new \"NOCOMPLETE\" flag.\n>\n> I wonder if this option should be named DANGEROUS rather than\n> NOCOMPLETE to better reflect its intention. The reason I ask is that\n> it is easy to imagine git-completion.bash some day growing a new\n> configuration option to allow people to complete these \"dangerous\"\n> options, as well, rather than us imposing, with no escape hatch, our\n> idea of what should and should not complete.\n>\n> It's not uncommon for \"bug reports\" to be sent to the list stating\n> that such-and-such option (say, --force) does not autocomplete. Our\n> stock answer is \"oh, that's a dangerous option, so you'll have to type\n> it manually\". If git-completion.bash gains new configuration to allow\n> dangerous options, then our answer can become \"oh, that's a dangerous\n> option, if you really want it to complete, then enable\n> GIT_COMPLETION_DANGEROUS\" (or whatever).\n\nI think we should just drop this idea of dangerous and complete things\nlike --force. On the same systems people use this on this will complete\n--force:\n\n    rm / --recurse --for<TAB>\n\nSo it's odd UI to be inconsistent with that. But if others disagree and\nwant to keep the current behavior I'd definitely turn the \"complete\n'dangerous'\" option.\n"},{"id":"338186","messageId":"CACsJy8AzKAGyAL_Pxpex3zF6G48=q8KCKvgJxOA_peqyM1cJug@mail.gmail.com","threadId":"47727","inReplyTo":"87y3k7lnnn.fsf@evledraar.gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-05T11:22:46Z","receivedAt":"2018-02-05T11:23:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Feb 5, 2018 at 5:46 PM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n>\n> On Wed, Jan 31 2018, Eric Sunshine jotted:\n>\n>> On Wed, Jan 31, 2018 at 6:05 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>>> This option is designed to be used by git-completion.bash. For many\n>>> simple cases, what we do in there is usually\n>>>\n>>>     __gitcomp \"lots of completion options\"\n>>>\n>>> which has to be manually updated when a new user-visible option is\n>>> added. With support from parse-options, we can write\n>>>\n>>>     __gitcomp \"$(git command --git-completion-helper)\"\n>>>\n>>> and get that list directly from the parser for free. Dangerous/Unpopular\n>>> options could be hidden with the new \"NOCOMPLETE\" flag.\n>>\n>> I wonder if this option should be named DANGEROUS rather than\n>> NOCOMPLETE to better reflect its intention. The reason I ask is that\n>> it is easy to imagine git-completion.bash some day growing a new\n>> configuration option to allow people to complete these \"dangerous\"\n>> options, as well, rather than us imposing, with no escape hatch, our\n>> idea of what should and should not complete.\n>>\n>> It's not uncommon for \"bug reports\" to be sent to the list stating\n>> that such-and-such option (say, --force) does not autocomplete. Our\n>> stock answer is \"oh, that's a dangerous option, so you'll have to type\n>> it manually\". If git-completion.bash gains new configuration to allow\n>> dangerous options, then our answer can become \"oh, that's a dangerous\n>> option, if you really want it to complete, then enable\n>> GIT_COMPLETION_DANGEROUS\" (or whatever).\n>\n> I think we should just drop this idea of dangerous and complete things\n> like --force. On the same systems people use this on this will complete\n> --force:\n>\n>     rm / --recurse --for<TAB>\n>\n> So it's odd UI to be inconsistent with that. But if others disagree and\n> want to keep the current behavior I'd definitely turn the \"complete\n> 'dangerous'\" option.\n\nPersonally I like completing all options too (and will be happier if\nplumbing commands are completable; it seems much less work to do that\nnow). But I don't know git-completion.bash history and don't want to\nrevisit why some options are filtered out or the inconsistency.\n-- \nDuy\n"},{"id":"338480","messageId":"CAPig+cSxxEn5q_5gv9JDXprnnocTTaLaugnhYmpHJz5tzOAkEg@mail.gmail.com","threadId":"47727","inReplyTo":"20180205095608.GA12370@ash","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-02-06T05:04:01Z","receivedAt":"2018-02-06T05:04:07Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Feb 5, 2018 at 4:56 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Thu, Feb 01, 2018 at 02:16:46PM -0500, Eric Sunshine wrote:\n>> On Thu, Feb 1, 2018 at 5:21 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n>> > On Thu, Feb 1, 2018 at 4:54 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> >> I don't see that as convincing argument for two classes of \"no\n>> >> complete\". Since git-completion.bash already special-cases\n>> >> rebase/am/cherry-pick for --continue|--abort|--skip, it is not far\n>> >> fetched that that special-case treatment can be extended slightly to\n>> >> also filter out those three options from the list returned by\n>> >> --git-completion-helper.\n>> >\n>> > I agree that is possible, but it's a bit tricky to do the filtering\n>> > right in bash (all options are sent back as one line instead of one\n>> > per line, which is easier to process by command line tools).\n>>\n>> Perhaps I'm missing something, but wouldn't filtering out those\n>> options directly in Bash require only this?\n>>\n>>     % x='--foo --bar --snoo'\n>>     % echo ${x/--bar}\n>>     --foo --snoo\n>\n> OK how about some thing like this fixup patch? __gitcomp_builtin now\n> allows to add extra options as well as remove some.\n>\n> -- 8< --\n>  __gitcomp_builtin ()\n>  {\n> +       local incl=\"$2\"\n> +       local excl=\"$3\"\n> +               options=\"$(__git ${cmd/_/ } --git-completion-helper) $incl \"\n> +               for i in $excl; do\n> +                       options=\"${options/$i /}\"\n\nIs 'options' guaranteed to end with a space? If not, then this\nexpulsion will fail for the very last option. I'd think you can get by\nfine with just \"${options/$i}\".\n"},{"id":"338654","messageId":"xmqqr2pw7ge3.fsf@gitster-ct.c.googlers.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"Re: [PATCH v2 00/41] Automate updating git-completion.bash a bit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-02-07T19:23:48Z","receivedAt":"2018-02-07T19:23:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> I posted a proof of concept a while back [1]. This is the full version.\n>\n> This series lets \"git\" binary help git-completion.bash to complete\n> --<stuff> so that when a new option is added, we don't have to update\n> git-completion.bash manually too (people often forget it). As a side\n> effect, about 180 more options are now completable.\n>\n> parse-options is updated to allow developers to flag certain options\n> not to be completable if they want finer control over it.  But by\n> default, new non-hidden options are completable. Negative forms must\n> be handled manually. That's for the next step.\n\nEverybody seems to be in favour of the approach taken by this\nseries.  Is it in a good enough shape that we can merge it to 'next'\nand then go incremental from now on?  Or do we want to keep it in\n'pu' to give easier access to volunteer guinea pigs and wait until\nthe way to handle '--no-foo' options are figured out?\n"},{"id":"338681","messageId":"20180207234152.5087-1-szeder.dev@gmail.com","threadId":"47727","inReplyTo":"CAPig+cSxxEn5q_5gv9JDXprnnocTTaLaugnhYmpHJz5tzOAkEg@mail.gmail.com","subject":"Re: [PATCH v2 01/41] parse-options: support --git-completion-helper","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2018-02-07T23:41:52Z","receivedAt":"2018-02-07T23:42:12Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"\n> > OK how about some thing like this fixup patch? __gitcomp_builtin now\n> > allows to add extra options as well as remove some.\n> >\n> > -- 8< --\n> >  __gitcomp_builtin ()\n> >  {\n> > +       local incl=\"$2\"\n> > +       local excl=\"$3\"\n> > +               options=\"$(__git ${cmd/_/ } --git-completion-helper) $incl \"\n> > +               for i in $excl; do\n> > +                       options=\"${options/$i /}\"\n> \n> Is 'options' guaranteed to end with a space?\n\nIt is, note the space before the closing double quote in:\n\n  options=\"$(__git ${cmd/_/ } --git-completion-helper) $incl \"\n\n> If not, then this\n> expulsion will fail for the very last option. I'd think you can get by\n> fine with just \"${options/$i}\".\n\nI would prefer a space both at the beginning and at the end of the\npattern.  Please excuse the contrived corner case, but it could still\nfail if the option to be excluded is a suffix of an other option:\n\n  $ o=\"$(echo --foo--bar --baz --bar) \"\n  $ echo \"'${o/--bar /}'\"       # exclude '--bar'\n  '--foo--baz --bar '\n\nMaybe we'll never have --opt--ions with a doubledash in them[1], but\nstill...\n\n  $ o=\" $(echo --foo--bar --baz --bar) \"\n  $ echo \"'${o/ --bar / }'\"\n  ' --foo--bar --baz '\n\n\n[1] - Interestingly, grep shows that the German translation does\n      contain a '--reset--author'.\n \n"},{"id":"338699","messageId":"CACsJy8AJGr_5vjDGVp7h-2DbOvi3=uY3waoSm+Ko-muAuLxdoA@mail.gmail.com","threadId":"47727","inReplyTo":"xmqqr2pw7ge3.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v2 00/41] Automate updating git-completion.bash a bit","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-08T12:05:08Z","receivedAt":"2018-02-08T12:05:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Feb 8, 2018 at 2:23 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>> I posted a proof of concept a while back [1]. This is the full version.\n>>\n>> This series lets \"git\" binary help git-completion.bash to complete\n>> --<stuff> so that when a new option is added, we don't have to update\n>> git-completion.bash manually too (people often forget it). As a side\n>> effect, about 180 more options are now completable.\n>>\n>> parse-options is updated to allow developers to flag certain options\n>> not to be completable if they want finer control over it.  But by\n>> default, new non-hidden options are completable. Negative forms must\n>> be handled manually. That's for the next step.\n>\n> Everybody seems to be in favour of the approach taken by this\n> series.  Is it in a good enough shape that we can merge it to 'next'\n> and then go incremental from now on?\n\nNot until v3. v2 breaks Mac OS because I used some fancy bash feature.\nThere are some good improvements in __gitcomp_builtin() suggested by\nEric and Szeder, which will be in v3 as well.\n\n> Or do we want to keep it in\n> 'pu' to give easier access to volunteer guinea pigs and wait until\n> the way to handle '--no-foo' options are figured out?\n\nOh the --no-foo thing is definitely not part of this version. Once\nthis series lands though, people can start improving --no-foo per\ncommand, even in parallel. \"git foo -h\" will also benefit from that\neffort because we will be able to show --no- form only when we mean to\nallow --no-.\n-- \nDuy\n"},{"id":"338819","messageId":"20180209110221.27224-1-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180131110547.20577-1-pclouds@gmail.com","subject":"[PATCH v3 00/42] Automate updating git-completion.bash a bit","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:39Z","receivedAt":"2018-02-09T11:02:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"v3 improves __gitcomp_builtin() function a bit to allows both adding\nextra options (to complement --git-completion-helper limitations) and\nremoving options.\n\nv3 should also fix Mac OS breakage.\n\nThe last change in 42/42 is a new configurable variable in\ngit-completion.bash that allows you to complete _all_ options,\nincluding ones that are filtered out by default. For the record there\nare 22 of them with the following counts:\n\n     10 --force\n      4 --rerere-autoupdate\n      1 --unsafe-paths\n      1 --thin\n      1 --overwrite-ignore\n      1 --open-files-in-pager\n      1 --null\n      1 --ext-grep\n      1 --exit-code\n      1 --auto\n\nThe first 41 patches should be ok to enter 'next' unless people find\nsomething else. 42/42 may be a bit more questionable (e.g.\nconfiguration variable name, or how we pass options to\n--git-completion-helper...) and might have to stay on 'pu' longer.\n\nInterdiff with v2 below. I remove changes that are reverts back to\n'master' to reduce the noise a bit.\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex cfd24c5764..0cfa489a8e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -36,6 +36,10 @@\n #\n #     When set to \"1\", do not include \"DWIM\" suggestions in git-checkout\n #     completion (e.g., completing \"foo\" when \"origin/foo\" exists).\n+#\n+#   GIT_COMPLETION_OPTIONS\n+#\n+#     When set to \"all\", complete all possible options\n \n case \"$COMP_WORDBREAKS\" in\n *:*) : great ;;\n@@ -284,24 +288,33 @@ __gitcomp ()\n #\n #    __gitcomp \"$(git xxx --git-completion-helper) ...\"\n #\n-# except that the value from $(git) is cached\n+# except that the output is cached. Accept 1-3 arguments:\n+# 1: the git command to execute, this is also the cache key\n+# 2: extra options to be added on top (e.g. negative forms)\n+# 3: options to be excluded\n __gitcomp_builtin ()\n {\n \t# spaces must be replaced with underscore for multi-word\n \t# commands, e.g. \"git remote add\" becomes remote_add.\n \tlocal cmd=\"$1\"\n-\tshift\n+\tlocal incl=\"$2\"\n+\tlocal excl=\"$3\"\n \n \tlocal var=__gitcomp_builtin_\"${cmd/-/_}\"\n \tlocal options\n \teval \"options=\\$$var\"\n \n \tif [ -z \"$options\" ]; then\n-\t\tdeclare -g \"$var=$(__git ${cmd/_/ } --git-completion-helper)\"\n-\t\teval \"options=\\$$var\"\n+\t\t# leading and trailing spaces are significant to make\n+\t\t# option removal work correctly.\n+\t\toptions=\" $(__git ${cmd/_/ } --git-completion-helper=$GIT_COMPLETION_OPTIONS) $incl \"\n+\t\tfor i in $excl; do\n+\t\t\toptions=\"${options/ $i / }\"\n+\t\tdone\n+\t\teval \"$var=\\\"$options\\\"\"\n \tfi\n \n-\t__gitcomp \"$options $*\"\n+\t__gitcomp \"$options\"\n }\n \n # Variation of __gitcomp_nl () that appends to the existing list of\n@@ -1096,12 +1109,13 @@ __git_count_arguments ()\n }\n \n __git_whitespacelist=\"nowarn warn error error-all fix\"\n+__git_am_inprogress_options=\"--skip --continue --resolved --abort\"\n \n _git_am ()\n {\n \t__git_find_repo_path\n \tif [ -d \"$__git_repo_path\"/rebase-apply ]; then\n-\t\t__gitcomp \"--skip --continue --resolved --abort\"\n+\t\t__gitcomp \"$__git_am_inprogress_options\"\n \t\treturn\n \tfi\n \tcase \"$cur\" in\n@@ -1110,7 +1124,8 @@ _git_am ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp_builtin am \"--no-utf8\"\n+\t\t__gitcomp_builtin am \"--no-utf8\" \\\n+\t\t\t\"$__git_am_inprogress_options\"\n \t\treturn\n \tesac\n }\n@@ -1272,16 +1287,19 @@ _git_cherry ()\n \t__git_complete_refs\n }\n \n+__git_cherry_pick_inprogress_options=\"--continue --quit --abort\"\n+\n _git_cherry_pick ()\n {\n \t__git_find_repo_path\n \tif [ -f \"$__git_repo_path\"/CHERRY_PICK_HEAD ]; then\n-\t\t__gitcomp \"--continue --quit --abort\"\n+\t\t__gitcomp \"$__git_cherry_pick_inprogress_options\"\n \t\treturn\n \tfi\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp_builtin cherry-pick\n+\t\t__gitcomp_builtin cherry-pick \"\" \\\n+\t\t\t\"$__git_cherry_pick_inprogress_options\"\n \t\t;;\n \t*)\n \t\t__git_complete_refs\n@@ -2674,16 +2692,19 @@ _git_reset ()\n \t__git_complete_refs\n }\n \n+__git_revert_inprogress_options=\"--continue --quit --abort\"\n+\n _git_revert ()\n {\n \t__git_find_repo_path\n \tif [ -f \"$__git_repo_path\"/REVERT_HEAD ]; then\n-\t\t__gitcomp \"--continue --quit --abort\"\n+\t\t__gitcomp \"$__git_revert_inprogress_options\"\n \t\treturn\n \tfi\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp_builtin revert \"--no-edit\"\n+\t\t__gitcomp_builtin revert \"--no-edit\" \\\n+\t\t\t\"$__git_revert_inprogress_options\"\n \t\treturn\n \t\t;;\n \tesac\ndiff --git a/parse-options.c b/parse-options.c\nindex 979577ba2c..5b8b2b376e 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -430,14 +430,17 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,\n  * many options that do not suppress it properly.\n  */\n static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n-\t\t\tconst struct option *opts)\n+\t\t\tconst struct option *opts,\n+\t\t\tconst char *arg)\n {\n \tfor (; opts->type != OPTION_END; opts++) {\n \t\tconst char *suffix = \"\";\n \n \t\tif (!opts->long_name)\n \t\t\tcontinue;\n-\t\tif (opts->flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE))\n+\t\tif (opts->flags & PARSE_OPT_HIDDEN)\n+\t\t\tcontinue;\n+\t\tif ((opts->flags & PARSE_OPT_NOCOMPLETE) && strcmp(arg, \"all\"))\n \t\t\tcontinue;\n \n \t\tswitch (opts->type) {\n@@ -498,8 +501,8 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,\n \t\t\tgoto show_usage;\n \n \t\t/* lone --git-completion-helper is asked by git-completion.bash */\n-\t\tif (ctx->total == 1 && !strcmp(arg + 1, \"-git-completion-helper\"))\n-\t\t\treturn show_gitcomp(ctx, options);\n+\t\tif (ctx->total == 1 && skip_prefix(arg + 1, \"-git-completion-helper=\", &arg))\n+\t\t\treturn show_gitcomp(ctx, options, arg);\n \n \t\tif (arg[1] != '-') {\n \t\t\tctx->opt = arg + 1;\ndiff --git a/parse-options.h b/parse-options.h\nindex f63151fbda..0ba08691e6 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -92,7 +92,7 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n  *\t\t\t\t(i.e. '<argh>') in the help message.\n  *\t\t\t\tUseful for options with multiple parameters.\n  *   PARSE_OPT_NOCOMPLETE: by default all visible options are completable\n- *\t\t\t   git-completion.bash. This option suppresses that.\n+ *\t\t\t   by git-completion.bash. This option suppresses that.\n  *   PARSE_OPT_COMP_ARG: this option forces to git-completion.bash to\n  *\t\t\t complete an option as --name= not --name even if\n  *\t\t\t the option takes optional argument.\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338820","messageId":"20180209110221.27224-2-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 01/42] parse-options: support --git-completion-helper","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:40Z","receivedAt":"2018-02-09T11:02:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This option is designed to be used by git-completion.bash. For many\nsimple cases, what we do in there is usually\n\n    __gitcomp \"lots of completion options\"\n\nwhich has to be manually updated when a new user-visible option is\nadded. With support from parse-options, we can write\n\n    __gitcomp \"$(git command --git-completion-helper)\"\n\nand get that list directly from the parser for free. Dangerous/Unpopular\noptions could be hidden with the new \"NOCOMPLETE\" flag.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n parse-options.c | 44 ++++++++++++++++++++++++++++++++++++++++++++\n parse-options.h |  5 ++++-\n 2 files changed, 48 insertions(+), 1 deletion(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex fca7159646..29f4defdd6 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -425,6 +425,46 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,\n \tparse_options_check(options);\n }\n \n+/*\n+ * TODO: we are not completing the --no-XXX form yet because there are\n+ * many options that do not suppress it properly.\n+ */\n+static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n+\t\t\tconst struct option *opts)\n+{\n+\tfor (; opts->type != OPTION_END; opts++) {\n+\t\tconst char *suffix = \"\";\n+\n+\t\tif (!opts->long_name)\n+\t\t\tcontinue;\n+\t\tif (opts->flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE))\n+\t\t\tcontinue;\n+\n+\t\tswitch (opts->type) {\n+\t\tcase OPTION_GROUP:\n+\t\t\tcontinue;\n+\t\tcase OPTION_STRING:\n+\t\tcase OPTION_FILENAME:\n+\t\tcase OPTION_INTEGER:\n+\t\tcase OPTION_MAGNITUDE:\n+\t\tcase OPTION_CALLBACK:\n+\t\t\tif (opts->flags & PARSE_OPT_NOARG)\n+\t\t\t\tbreak;\n+\t\t\tif (opts->flags & PARSE_OPT_OPTARG)\n+\t\t\t\tbreak;\n+\t\t\tif (opts->flags & PARSE_OPT_LASTARG_DEFAULT)\n+\t\t\t\tbreak;\n+\t\t\tsuffix = \"=\";\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\t\tprintf(\" --%s%s\", opts->long_name, suffix);\n+\t}\n+\tfputc('\\n', stdout);\n+\texit(0);\n+}\n+\n static int usage_with_options_internal(struct parse_opt_ctx_t *,\n \t\t\t\t       const char * const *,\n \t\t\t\t       const struct option *, int, int);\n@@ -455,6 +495,10 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,\n \t\tif (internal_help && ctx->total == 1 && !strcmp(arg + 1, \"h\"))\n \t\t\tgoto show_usage;\n \n+\t\t/* lone --git-completion-helper is asked by git-completion.bash */\n+\t\tif (ctx->total == 1 && !strcmp(arg + 1, \"-git-completion-helper\"))\n+\t\t\treturn show_gitcomp(ctx, options);\n+\n \t\tif (arg[1] != '-') {\n \t\t\tctx->opt = arg + 1;\n \t\t\tswitch (parse_short_opt(ctx, options)) {\ndiff --git a/parse-options.h b/parse-options.h\nindex af711227ae..a5caa0bb1d 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -38,7 +38,8 @@ enum parse_opt_option_flags {\n \tPARSE_OPT_LASTARG_DEFAULT = 16,\n \tPARSE_OPT_NODASH = 32,\n \tPARSE_OPT_LITERAL_ARGHELP = 64,\n-\tPARSE_OPT_SHELL_EVAL = 256\n+\tPARSE_OPT_SHELL_EVAL = 256,\n+\tPARSE_OPT_NOCOMPLETE = 512\n };\n \n struct option;\n@@ -89,6 +90,8 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n  *   PARSE_OPT_LITERAL_ARGHELP: says that argh shouldn't be enclosed in brackets\n  *\t\t\t\t(i.e. '<argh>') in the help message.\n  *\t\t\t\tUseful for options with multiple parameters.\n+ *   PARSE_OPT_NOCOMPLETE: by default all visible options are completable\n+ *\t\t\t   by git-completion.bash. This option suppresses that.\n  *\n  * `callback`::\n  *   pointer to the callback to use for OPTION_CALLBACK or\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338821","messageId":"20180209110221.27224-3-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 02/42] parse-options: add OPT_xxx_F() variants","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:41Z","receivedAt":"2018-02-09T11:02:52Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"These macros allow us to add extra parse-options flag, the main one in\nmy mind is PARSE_OPT_NOCOMPLETE to hide certain options from\n--git-completion-helper.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n parse-options.h | 19 ++++++++++++-------\n 1 file changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/parse-options.h b/parse-options.h\nindex a5caa0bb1d..05a6839019 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -115,19 +115,24 @@ struct option {\n \tintptr_t defval;\n };\n \n+#define OPT_BIT_F(s, l, v, h, b, f) { OPTION_BIT, (s), (l), (v), NULL, (h), \\\n+\t\t\t\t      PARSE_OPT_NOARG|(f), NULL, (b) }\n+#define OPT_COUNTUP_F(s, l, v, h, f) { OPTION_COUNTUP, (s), (l), (v), NULL, \\\n+\t\t\t\t       (h), PARSE_OPT_NOARG|(f) }\n+#define OPT_SET_INT_F(s, l, v, h, i, f) { OPTION_SET_INT, (s), (l), (v), NULL, \\\n+\t\t\t\t\t  (h), PARSE_OPT_NOARG | (f), NULL, (i) }\n+#define OPT_BOOL_F(s, l, v, h, f)   OPT_SET_INT_F(s, l, v, h, 1, f)\n+\n #define OPT_END()                   { OPTION_END }\n #define OPT_ARGUMENT(l, h)          { OPTION_ARGUMENT, 0, (l), NULL, NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG}\n #define OPT_GROUP(h)                { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }\n-#define OPT_BIT(s, l, v, h, b)      { OPTION_BIT, (s), (l), (v), NULL, (h), \\\n-\t\t\t\t      PARSE_OPT_NOARG, NULL, (b) }\n+#define OPT_BIT(s, l, v, h, b)      OPT_BIT_F(s, l, v, h, b, 0)\n #define OPT_NEGBIT(s, l, v, h, b)   { OPTION_NEGBIT, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG, NULL, (b) }\n-#define OPT_COUNTUP(s, l, v, h)     { OPTION_COUNTUP, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG }\n-#define OPT_SET_INT(s, l, v, h, i)  { OPTION_SET_INT, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG, NULL, (i) }\n-#define OPT_BOOL(s, l, v, h)        OPT_SET_INT(s, l, v, h, 1)\n+#define OPT_COUNTUP(s, l, v, h)     OPT_COUNTUP_F(s, l, v, h, 0)\n+#define OPT_SET_INT(s, l, v, h, i)  OPT_SET_INT_F(s, l, v, h, i, 0)\n+#define OPT_BOOL(s, l, v, h)        OPT_BOOL_F(s, l, v, h, 0)\n #define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}\n #define OPT_CMDMODE(s, l, v, h, i)  { OPTION_CMDMODE, (s), (l), (v), NULL, \\\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338822","messageId":"20180209110221.27224-4-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 03/42] parse-options: let OPT__FORCE take optional flags argument","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:42Z","receivedAt":"2018-02-09T11:02:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"--force option is most likely hidden from command line completion for\nsafety reasons. This is done by adding an extra flag\nPARSE_OPT_NOCOMPLETE. Update OPT__FORCE() to accept additional\nflags. Actual flag change comes later depending on individual\ncommands.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/add.c                | 2 +-\n builtin/branch.c             | 2 +-\n builtin/checkout-index.c     | 2 +-\n builtin/checkout.c           | 2 +-\n builtin/clean.c              | 2 +-\n builtin/fetch.c              | 2 +-\n builtin/mv.c                 | 2 +-\n builtin/notes.c              | 4 ++--\n builtin/pull.c               | 2 +-\n builtin/rm.c                 | 2 +-\n builtin/tag.c                | 2 +-\n builtin/update-server-info.c | 2 +-\n builtin/worktree.c           | 4 +++-\n parse-options.h              | 2 +-\n 14 files changed, 17 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex bf01d89e28..ac7c1c3277 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -294,7 +294,7 @@ static struct option builtin_add_options[] = {\n \tOPT_BOOL('i', \"interactive\", &add_interactive, N_(\"interactive picking\")),\n \tOPT_BOOL('p', \"patch\", &patch_interactive, N_(\"select hunks interactively\")),\n \tOPT_BOOL('e', \"edit\", &edit_interactive, N_(\"edit current diff and apply\")),\n-\tOPT__FORCE(&ignored_too, N_(\"allow adding otherwise ignored files\")),\n+\tOPT__FORCE(&ignored_too, N_(\"allow adding otherwise ignored files\"), 0),\n \tOPT_BOOL('u', \"update\", &take_worktree_changes, N_(\"update tracked files\")),\n \tOPT_BOOL(0, \"renormalize\", &add_renormalize, N_(\"renormalize EOL of tracked files (implies -u)\")),\n \tOPT_BOOL('N', \"intent-to-add\", &intent_to_add, N_(\"record only the fact that the path will be added later\")),\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 8dcc2ed058..b5b62c08ba 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -615,7 +615,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL('l', \"create-reflog\", &reflog, N_(\"create the branch's reflog\")),\n \t\tOPT_BOOL(0, \"edit-description\", &edit_description,\n \t\t\t N_(\"edit the description for the branch\")),\n-\t\tOPT__FORCE(&force, N_(\"force creation, move/rename, deletion\")),\n+\t\tOPT__FORCE(&force, N_(\"force creation, move/rename, deletion\"), 0),\n \t\tOPT_MERGED(&filter, N_(\"print only branches that are merged\")),\n \t\tOPT_NO_MERGED(&filter, N_(\"print only branches that are not merged\")),\n \t\tOPT_COLUMN(0, \"column\", &colopts, N_(\"list branches in columns\")),\ndiff --git a/builtin/checkout-index.c b/builtin/checkout-index.c\nindex b0e78b819d..a730f6a1aa 100644\n--- a/builtin/checkout-index.c\n+++ b/builtin/checkout-index.c\n@@ -157,7 +157,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n \tstruct option builtin_checkout_index_options[] = {\n \t\tOPT_BOOL('a', \"all\", &all,\n \t\t\tN_(\"check out all files in the index\")),\n-\t\tOPT__FORCE(&force, N_(\"force overwrite of existing files\")),\n+\t\tOPT__FORCE(&force, N_(\"force overwrite of existing files\"), 0),\n \t\tOPT__QUIET(&quiet,\n \t\t\tN_(\"no warning for existing files and files not in index\")),\n \t\tOPT_BOOL('n', \"no-create\", &not_new,\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex c54c78df54..2a96358eb7 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1118,7 +1118,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\t\t    2),\n \t\tOPT_SET_INT('3', \"theirs\", &opts.writeout_stage, N_(\"checkout their version for unmerged files\"),\n \t\t\t    3),\n-\t\tOPT__FORCE(&opts.force, N_(\"force checkout (throw away local modifications)\")),\n+\t\tOPT__FORCE(&opts.force, N_(\"force checkout (throw away local modifications)\"), 0),\n \t\tOPT_BOOL('m', \"merge\", &opts.merge, N_(\"perform a 3-way merge with the new branch\")),\n \t\tOPT_BOOL(0, \"overwrite-ignore\", &opts.overwrite_ignore, N_(\"update ignored files (default)\")),\n \t\tOPT_STRING(0, \"conflict\", &conflict_style, N_(\"style\"),\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 189e20628c..3c4ca9a2ff 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -909,7 +909,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__QUIET(&quiet, N_(\"do not print names of files removed\")),\n \t\tOPT__DRY_RUN(&dry_run, N_(\"dry run\")),\n-\t\tOPT__FORCE(&force, N_(\"force\")),\n+\t\tOPT__FORCE(&force, N_(\"force\"), 0),\n \t\tOPT_BOOL('i', \"interactive\", &interactive, N_(\"interactive cleaning\")),\n \t\tOPT_BOOL('d', NULL, &remove_directories,\n \t\t\t\tN_(\"remove whole directories\")),\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 7bbcd26faf..6a603174fb 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -115,7 +115,7 @@ static struct option builtin_fetch_options[] = {\n \t\t N_(\"append to .git/FETCH_HEAD instead of overwriting\")),\n \tOPT_STRING(0, \"upload-pack\", &upload_pack, N_(\"path\"),\n \t\t   N_(\"path to upload pack on remote end\")),\n-\tOPT__FORCE(&force, N_(\"force overwrite of local branch\")),\n+\tOPT__FORCE(&force, N_(\"force overwrite of local branch\"), 0),\n \tOPT_BOOL('m', \"multiple\", &multiple,\n \t\t N_(\"fetch from multiple remotes\")),\n \tOPT_SET_INT('t', \"tags\", &tags,\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex cf3684d907..b88023a733 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -122,7 +122,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \tstruct option builtin_mv_options[] = {\n \t\tOPT__VERBOSE(&verbose, N_(\"be verbose\")),\n \t\tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n-\t\tOPT__FORCE(&force, N_(\"force move/rename even if target exists\")),\n+\t\tOPT__FORCE(&force, N_(\"force move/rename even if target exists\"), 0),\n \t\tOPT_BOOL('k', NULL, &ignore_errors, N_(\"skip move/rename errors\")),\n \t\tOPT_END(),\n \t};\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 7c81761645..b52e71c73e 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -413,7 +413,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\tparse_reuse_arg},\n \t\tOPT_BOOL(0, \"allow-empty\", &allow_empty,\n \t\t\tN_(\"allow storing empty note\")),\n-\t\tOPT__FORCE(&force, N_(\"replace existing notes\")),\n+\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), 0),\n \t\tOPT_END()\n \t};\n \n@@ -484,7 +484,7 @@ static int copy(int argc, const char **argv, const char *prefix)\n \tstruct notes_tree *t;\n \tconst char *rewrite_cmd = NULL;\n \tstruct option options[] = {\n-\t\tOPT__FORCE(&force, N_(\"replace existing notes\")),\n+\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), 0),\n \t\tOPT_BOOL(0, \"stdin\", &from_stdin, N_(\"read objects from stdin\")),\n \t\tOPT_STRING(0, \"for-rewrite\", &rewrite_cmd, N_(\"command\"),\n \t\t\t   N_(\"load rewriting config for <command> (implies \"\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 511dbbe0f6..652239aae9 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -193,7 +193,7 @@ static struct option pull_options[] = {\n \tOPT_PASSTHRU(0, \"upload-pack\", &opt_upload_pack, N_(\"path\"),\n \t\tN_(\"path to upload pack on remote end\"),\n \t\t0),\n-\tOPT__FORCE(&opt_force, N_(\"force overwrite of local branch\")),\n+\tOPT__FORCE(&opt_force, N_(\"force overwrite of local branch\"), 0),\n \tOPT_PASSTHRU('t', \"tags\", &opt_tags, NULL,\n \t\tN_(\"fetch all tags and associated objects\"),\n \t\tPARSE_OPT_NOARG),\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 4a2fcca27b..6e0c7f5ac6 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -242,7 +242,7 @@ static struct option builtin_rm_options[] = {\n \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n \tOPT__QUIET(&quiet, N_(\"do not list removed files\")),\n \tOPT_BOOL( 0 , \"cached\",         &index_only, N_(\"only remove from the index\")),\n-\tOPT__FORCE(&force, N_(\"override the up-to-date check\")),\n+\tOPT__FORCE(&force, N_(\"override the up-to-date check\"), 0),\n \tOPT_BOOL('r', NULL,             &recursive,  N_(\"allow recursive removal\")),\n \tOPT_BOOL( 0 , \"ignore-unmatch\", &ignore_unmatch,\n \t\t\t\tN_(\"exit with a zero status even if nothing matched\")),\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex a7e6a5b0f2..98d3956bbe 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -391,7 +391,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"how to strip spaces and #comments from message\")),\n \t\tOPT_STRING('u', \"local-user\", &keyid, N_(\"key-id\"),\n \t\t\t\t\tN_(\"use another key to sign the tag\")),\n-\t\tOPT__FORCE(&force, N_(\"replace the tag if exists\")),\n+\t\tOPT__FORCE(&force, N_(\"replace the tag if exists\"), 0),\n \t\tOPT_BOOL(0, \"create-reflog\", &create_reflog, N_(\"create a reflog\")),\n \n \t\tOPT_GROUP(N_(\"Tag listing options\")),\ndiff --git a/builtin/update-server-info.c b/builtin/update-server-info.c\nindex 873070e517..4321a34456 100644\n--- a/builtin/update-server-info.c\n+++ b/builtin/update-server-info.c\n@@ -12,7 +12,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix)\n {\n \tint force = 0;\n \tstruct option options[] = {\n-\t\tOPT__FORCE(&force, N_(\"update the info files from scratch\")),\n+\t\tOPT__FORCE(&force, N_(\"update the info files from scratch\"), 0),\n \t\tOPT_END()\n \t};\n \ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 7cef5b120b..4d3422f62e 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -365,7 +365,9 @@ static int add(int ac, const char **av, const char *prefix)\n \tconst char *branch;\n \tconst char *opt_track = NULL;\n \tstruct option options[] = {\n-\t\tOPT__FORCE(&opts.force, N_(\"checkout <branch> even if already checked out in other worktree\")),\n+\t\tOPT__FORCE(&opts.force,\n+\t\t\t   N_(\"checkout <branch> even if already checked out in other worktree\"),\n+\t\t\t   0),\n \t\tOPT_STRING('b', NULL, &opts.new_branch, N_(\"branch\"),\n \t\t\t   N_(\"create a new branch\")),\n \t\tOPT_STRING('B', NULL, &new_branch_force, N_(\"branch\"),\ndiff --git a/parse-options.h b/parse-options.h\nindex 05a6839019..3c32401736 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -248,7 +248,7 @@ extern int parse_opt_passthru_argv(const struct option *, const char *, int);\n \t{ OPTION_CALLBACK, 'q', \"quiet\", (var), NULL, N_(\"be more quiet\"), \\\n \t  PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }\n #define OPT__DRY_RUN(var, h)  OPT_BOOL('n', \"dry-run\", (var), (h))\n-#define OPT__FORCE(var, h)    OPT_COUNTUP('f', \"force\",   (var), (h))\n+#define OPT__FORCE(var, h, f) OPT_COUNTUP_F('f', \"force\",   (var), (h), (f))\n #define OPT__ABBREV(var)  \\\n \t{ OPTION_CALLBACK, 0, \"abbrev\", (var), N_(\"n\"),\t\\\n \t  N_(\"use <n> digits to display SHA-1s\"),\t\\\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338823","messageId":"20180209110221.27224-5-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 04/42] git-completion.bash: introduce __gitcomp_builtin","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:43Z","receivedAt":"2018-02-09T11:03:03Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This is a __gitcomp wrapper that will execute\n\n    git ... --git-completion-helper\n\nto get the list of completable options. The call will be made only\nonce and cached to avoid performance issues, especially on Windows.\n\n__gitcomp_builtin() allows callers to change its output a bit by adding\nsome more options, or removing some.\n\n- Current --git-completion-helper for example does not output --no-foo\n  form, this has to be added manually by __gitcomp_builtin() callers\n  when necessary\n\n- Some options from --git-completion-helper should only be available in\n  certain conditions (e.g. --continue and friends). __gitcomp_builtin()\n  callers can remove them if the conditions are not met.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 33 ++++++++++++++++++++++++++\n 1 file changed, 33 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3683c772c5..85e7f26328 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -280,6 +280,39 @@ __gitcomp ()\n \tesac\n }\n \n+# This function is equivalent to\n+#\n+#    __gitcomp \"$(git xxx --git-completion-helper) ...\"\n+#\n+# except that the output is cached. Accept 1-3 arguments:\n+# 1: the git command to execute, this is also the cache key\n+# 2: extra options to be added on top (e.g. negative forms)\n+# 3: options to be excluded\n+__gitcomp_builtin ()\n+{\n+\t# spaces must be replaced with underscore for multi-word\n+\t# commands, e.g. \"git remote add\" becomes remote_add.\n+\tlocal cmd=\"$1\"\n+\tlocal incl=\"$2\"\n+\tlocal excl=\"$3\"\n+\n+\tlocal var=__gitcomp_builtin_\"${cmd/-/_}\"\n+\tlocal options\n+\teval \"options=\\$$var\"\n+\n+\tif [ -z \"$options\" ]; then\n+\t\t# leading and trailing spaces are significant to make\n+\t\t# option removal work correctly.\n+\t\toptions=\" $(__git ${cmd/_/ } --git-completion-helper) $incl \"\n+\t\tfor i in $excl; do\n+\t\t\toptions=\"${options/ $i / }\"\n+\t\tdone\n+\t\teval \"$var=\\\"$options\\\"\"\n+\tfi\n+\n+\t__gitcomp \"$options\"\n+}\n+\n # Variation of __gitcomp_nl () that appends to the existing list of\n # completion candidates, COMPREPLY.\n __gitcomp_nl_append ()\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338824","messageId":"20180209110221.27224-6-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 05/42] completion: use __gitcomp_builtin in _git_add","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:44Z","receivedAt":"2018-02-09T11:03:08Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are\n\n--all\n--ignore-missing\n--ignore-removal\n--renormalize\n--verbose\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 85e7f26328..1e0bd835fe 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1153,10 +1153,7 @@ _git_add ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--interactive --refresh --patch --update --dry-run\n-\t\t\t--ignore-errors --intent-to-add --force --edit --chmod=\n-\t\t\t\"\n+\t\t__gitcomp_builtin add\n \t\treturn\n \tesac\n \n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338825","messageId":"20180209110221.27224-7-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 06/42] completion: use __gitcomp_builtin in _git_am","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:45Z","receivedAt":"2018-02-09T11:03:14Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--directory\n--exclude\n--gpg-sign\n--include\n--keep-cr\n--keep-non-patch\n--message-id\n--no-keep-cr\n--patch-format\n--quiet\n--reject\n--resolvemsg=\n\nIn-progress options like --continue will be part of --git-completion-helper\nthen filtered out by _git_am() unless the operation is in progress. This\nhelps keep marking of these operations in just one place.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 11 ++++-------\n parse-options.h                        |  4 ++--\n rerere.h                               |  3 ++-\n 3 files changed, 8 insertions(+), 10 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1e0bd835fe..eba482eb9c 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1105,12 +1105,13 @@ __git_count_arguments ()\n }\n \n __git_whitespacelist=\"nowarn warn error error-all fix\"\n+__git_am_inprogress_options=\"--skip --continue --resolved --abort\"\n \n _git_am ()\n {\n \t__git_find_repo_path\n \tif [ -d \"$__git_repo_path\"/rebase-apply ]; then\n-\t\t__gitcomp \"--skip --continue --resolved --abort\"\n+\t\t__gitcomp \"$__git_am_inprogress_options\"\n \t\treturn\n \tfi\n \tcase \"$cur\" in\n@@ -1119,12 +1120,8 @@ _git_am ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--3way --committer-date-is-author-date --ignore-date\n-\t\t\t--ignore-whitespace --ignore-space-change\n-\t\t\t--interactive --keep --no-utf8 --signoff --utf8\n-\t\t\t--whitespace= --scissors\n-\t\t\t\"\n+\t\t__gitcomp_builtin am \"--no-utf8\" \\\n+\t\t\t\"$__git_am_inprogress_options\"\n \t\treturn\n \tesac\n }\ndiff --git a/parse-options.h b/parse-options.h\nindex 3c32401736..009cd863e5 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -144,8 +144,8 @@ struct option {\n #define OPT_STRING_LIST(s, l, v, a, h) \\\n \t\t\t\t    { OPTION_CALLBACK, (s), (l), (v), (a), \\\n \t\t\t\t      (h), 0, &parse_opt_string_list }\n-#define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG, &parse_opt_tertiary }\n+#define OPT_UYN(s, l, v, h, f)      { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n+\t\t\t\t      (h), PARSE_OPT_NOARG|(f), &parse_opt_tertiary }\n #define OPT_DATE(s, l, v, h) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), N_(\"time\"),(h), 0,\t\\\n \t  parse_opt_approxidate_cb }\ndiff --git a/rerere.h b/rerere.h\nindex c2961feaaa..5e5a312e4c 100644\n--- a/rerere.h\n+++ b/rerere.h\n@@ -37,6 +37,7 @@ extern void rerere_clear(struct string_list *);\n extern void rerere_gc(struct string_list *);\n \n #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, \"rerere-autoupdate\", (v), \\\n-\tN_(\"update the index with reused conflict resolution if possible\"))\n+\tN_(\"update the index with reused conflict resolution if possible\"), \\\n+\tPARSE_OPT_NOCOMPLETE)\n \n #endif\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338826","messageId":"20180209110221.27224-8-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 07/42] completion: use __gitcomp_builtin in _git_apply","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:46Z","receivedAt":"2018-02-09T11:03:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--3way\n--allow-overlap\n--build-fake-ancestor=\n--directory\n--exclude\n--include\n\n--index-info is no longer completable but that's because it's renamed to\n--build-fake-ancestor in 26b2800768 (apply: get rid of --index-info in\nfavor of --build-fake-ancestor - 2007-09-17)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n apply.c                                | 5 +++--\n contrib/completion/git-completion.bash | 9 +--------\n 2 files changed, 4 insertions(+), 10 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 321a9fa68d..65eb37e6a4 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4943,8 +4943,9 @@ int apply_parse_options(int argc, const char **argv,\n \t\t\tN_(\"make sure the patch is applicable to the current index\")),\n \t\tOPT_BOOL(0, \"cached\", &state->cached,\n \t\t\tN_(\"apply a patch without touching the working tree\")),\n-\t\tOPT_BOOL(0, \"unsafe-paths\", &state->unsafe_paths,\n-\t\t\tN_(\"accept a patch that touches outside the working area\")),\n+\t\tOPT_BOOL_F(0, \"unsafe-paths\", &state->unsafe_paths,\n+\t\t\t   N_(\"accept a patch that touches outside the working area\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"apply\", force_apply,\n \t\t\tN_(\"also apply the patch (use with --stat/--summary/--check)\")),\n \t\tOPT_BOOL('3', \"3way\", &state->threeway,\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex eba482eb9c..2fd3fc999e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1134,14 +1134,7 @@ _git_apply ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--stat --numstat --summary --check --index\n-\t\t\t--cached --index-info --reverse --reject --unidiff-zero\n-\t\t\t--apply --no-add --exclude=\n-\t\t\t--ignore-whitespace --ignore-space-change\n-\t\t\t--whitespace= --inaccurate-eof --verbose\n-\t\t\t--recount --directory=\n-\t\t\t\"\n+\t\t__gitcomp_builtin apply\n \t\treturn\n \tesac\n }\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338827","messageId":"20180209110221.27224-9-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 08/42] completion: use __gitcomp_builtin in _git_branch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:47Z","receivedAt":"2018-02-09T11:03:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--all\n--create-reflog\n--format=\n--ignore-case\n--quiet\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/branch.c                       | 2 +-\n contrib/completion/git-completion.bash | 8 ++------\n 2 files changed, 3 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex b5b62c08ba..6d0cea9d4b 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -615,7 +615,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL('l', \"create-reflog\", &reflog, N_(\"create the branch's reflog\")),\n \t\tOPT_BOOL(0, \"edit-description\", &edit_description,\n \t\t\t N_(\"edit the description for the branch\")),\n-\t\tOPT__FORCE(&force, N_(\"force creation, move/rename, deletion\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"force creation, move/rename, deletion\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_MERGED(&filter, N_(\"print only branches that are merged\")),\n \t\tOPT_NO_MERGED(&filter, N_(\"print only branches that are not merged\")),\n \t\tOPT_COLUMN(0, \"column\", &colopts, N_(\"list branches in columns\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 2fd3fc999e..d926518fb7 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1220,12 +1220,8 @@ _git_branch ()\n \t\t__git_complete_refs --cur=\"${cur##--set-upstream-to=}\"\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--color --no-color --verbose --abbrev= --no-abbrev\n-\t\t\t--track --no-track --contains --no-contains --merged --no-merged\n-\t\t\t--set-upstream-to= --edit-description --list\n-\t\t\t--unset-upstream --delete --move --copy --remotes\n-\t\t\t--column --no-column --sort= --points-at\n+\t\t__gitcomp_builtin branch \"--no-color --no-abbrev\n+\t\t\t--no-track --no-column\n \t\t\t\"\n \t\t;;\n \t*)\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338828","messageId":"20180209110221.27224-10-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 09/42] completion: use __gitcomp_builtin in _git_checkout","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:48Z","receivedAt":"2018-02-09T11:03:29Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--ignore-other-worktrees\n--progress\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/checkout.c                     |  7 +++++--\n contrib/completion/git-completion.bash |  6 +-----\n t/t9902-completion.sh                  | 12 +++++++-----\n 3 files changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 2a96358eb7..a6218024a6 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1118,9 +1118,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\t\t    2),\n \t\tOPT_SET_INT('3', \"theirs\", &opts.writeout_stage, N_(\"checkout their version for unmerged files\"),\n \t\t\t    3),\n-\t\tOPT__FORCE(&opts.force, N_(\"force checkout (throw away local modifications)\"), 0),\n+\t\tOPT__FORCE(&opts.force, N_(\"force checkout (throw away local modifications)\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('m', \"merge\", &opts.merge, N_(\"perform a 3-way merge with the new branch\")),\n-\t\tOPT_BOOL(0, \"overwrite-ignore\", &opts.overwrite_ignore, N_(\"update ignored files (default)\")),\n+\t\tOPT_BOOL_F(0, \"overwrite-ignore\", &opts.overwrite_ignore,\n+\t\t\t   N_(\"update ignored files (default)\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_STRING(0, \"conflict\", &conflict_style, N_(\"style\"),\n \t\t\t   N_(\"conflict style (merge or diff3)\")),\n \t\tOPT_BOOL('p', \"patch\", &opts.patch_mode, N_(\"select hunks interactively\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex d926518fb7..7e312f95e9 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1263,11 +1263,7 @@ _git_checkout ()\n \t\t__gitcomp \"diff3 merge\" \"\" \"${cur##--conflict=}\"\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--quiet --ours --theirs --track --no-track --merge\n-\t\t\t--conflict= --orphan --patch --detach --ignore-skip-worktree-bits\n-\t\t\t--recurse-submodules --no-recurse-submodules\n-\t\t\t\"\n+\t\t__gitcomp_builtin checkout \"--no-track --no-recurse-submodules\"\n \t\t;;\n \t*)\n \t\t# check if --track, --no-track, or --no-guess was specified\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex fc614dcbfa..e6485feb0a 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -1237,17 +1237,19 @@ test_expect_success 'double dash \"git\" itself' '\n test_expect_success 'double dash \"git checkout\"' '\n \ttest_completion \"git checkout --\" <<-\\EOF\n \t--quiet Z\n+\t--detach Z\n+\t--track Z\n+\t--orphan=Z\n \t--ours Z\n \t--theirs Z\n-\t--track Z\n-\t--no-track Z\n \t--merge Z\n-\t--conflict=\n-\t--orphan Z\n+\t--conflict=Z\n \t--patch Z\n-\t--detach Z\n \t--ignore-skip-worktree-bits Z\n+\t--ignore-other-worktrees Z\n \t--recurse-submodules Z\n+\t--progress Z\n+\t--no-track Z\n \t--no-recurse-submodules Z\n \tEOF\n '\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338829","messageId":"20180209110221.27224-11-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 10/42] completion: use __gitcomp_builtin in _git_cherry_pick","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:49Z","receivedAt":"2018-02-09T11:03:34Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--allow-empty\n--allow-empty-message\n--ff\n--gpg-sign\n--keep-redundant-commits\n--strategy-option\n\nIn-progress options like --continue will be part of --git-completion-helper\nthen filtered out by _git_cherry_pick() unless the operation is in\nprogress. This helps keep marking of these operations in just one place.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7e312f95e9..068def9f6b 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1283,16 +1283,19 @@ _git_cherry ()\n \t__git_complete_refs\n }\n \n+__git_cherry_pick_inprogress_options=\"--continue --quit --abort\"\n+\n _git_cherry_pick ()\n {\n \t__git_find_repo_path\n \tif [ -f \"$__git_repo_path\"/CHERRY_PICK_HEAD ]; then\n-\t\t__gitcomp \"--continue --quit --abort\"\n+\t\t__gitcomp \"$__git_cherry_pick_inprogress_options\"\n \t\treturn\n \tfi\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--edit --no-commit --signoff --strategy= --mainline\"\n+\t\t__gitcomp_builtin cherry-pick \"\" \\\n+\t\t\t\"$__git_cherry_pick_inprogress_options\"\n \t\t;;\n \t*)\n \t\t__git_complete_refs\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338830","messageId":"20180209110221.27224-12-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 11/42] completion: use __gitcomp_builtin in _git_clean","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:50Z","receivedAt":"2018-02-09T11:03:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are --exclude and --interactive\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/clean.c                        | 2 +-\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 3c4ca9a2ff..fad533a0a7 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -909,7 +909,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__QUIET(&quiet, N_(\"do not print names of files removed\")),\n \t\tOPT__DRY_RUN(&dry_run, N_(\"dry run\")),\n-\t\tOPT__FORCE(&force, N_(\"force\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"force\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('i', \"interactive\", &interactive, N_(\"interactive cleaning\")),\n \t\tOPT_BOOL('d', NULL, &remove_directories,\n \t\t\t\tN_(\"remove whole directories\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 068def9f6b..b7de381876 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1307,7 +1307,7 @@ _git_clean ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--dry-run --quiet\"\n+\t\t__gitcomp_builtin clean\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338831","messageId":"20180209110221.27224-13-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 12/42] completion: use __gitcomp_builtin in _git_clone","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:51Z","receivedAt":"2018-02-09T11:03:48Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--config\n--dissociate\n--ipv4\n--ipv6\n--jobs=\n--progress\n--reference-if-able\n--separate-git-dir=\n--shallow-exclude\n--shallow-since=\n--verbose\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 21 +--------------------\n 1 file changed, 1 insertion(+), 20 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex b7de381876..6afab02a4c 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1320,26 +1320,7 @@ _git_clone ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--local\n-\t\t\t--no-hardlinks\n-\t\t\t--shared\n-\t\t\t--reference\n-\t\t\t--quiet\n-\t\t\t--no-checkout\n-\t\t\t--bare\n-\t\t\t--mirror\n-\t\t\t--origin\n-\t\t\t--upload-pack\n-\t\t\t--template=\n-\t\t\t--depth\n-\t\t\t--single-branch\n-\t\t\t--no-tags\n-\t\t\t--branch\n-\t\t\t--recurse-submodules\n-\t\t\t--no-single-branch\n-\t\t\t--shallow-submodules\n-\t\t\t\"\n+\t\t__gitcomp_builtin clone \"--no-single-branch\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338832","messageId":"20180209110221.27224-14-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 13/42] completion: use __gitcomp_builtin in _git_commit","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:52Z","receivedAt":"2018-02-09T11:03:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new comletable options are:\n\n--branch\n--gpg-sign\n--long\n--no-post-rewrite\n--null\n--porcelain\n--status\n\n--allow-empty is no longer completable because it's a hidden option\nsince 4741edd549 (Remove deprecated OPTION_BOOLEAN for parsing arguments\n- 2013-08-03)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 11 +----------\n 1 file changed, 1 insertion(+), 10 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6afab02a4c..0350350079 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1353,16 +1353,7 @@ _git_commit ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--all --author= --signoff --verify --no-verify\n-\t\t\t--edit --no-edit\n-\t\t\t--amend --include --only --interactive\n-\t\t\t--dry-run --reuse-message= --reedit-message=\n-\t\t\t--reset-author --file= --message= --template=\n-\t\t\t--cleanup= --untracked-files --untracked-files=\n-\t\t\t--verbose --quiet --fixup= --squash=\n-\t\t\t--patch --short --date --allow-empty\n-\t\t\t\"\n+\t\t__gitcomp_builtin commit \"--no-edit --verify\"\n \t\treturn\n \tesac\n \n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338833","messageId":"20180209110221.27224-15-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 14/42] completion: use __gitcomp_builtin in _git_config","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:53Z","receivedAt":"2018-02-09T11:03:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--blob=\n--bool\n--bool-or-int\n--edit\n--expiry-date\n--get-color\n--get-colorbool\n--get-urlmatch\n--includes\n--int\n--null\n--path\n--show-origin\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 9 +--------\n 1 file changed, 1 insertion(+), 8 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0350350079..6e17caf8d7 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2252,14 +2252,7 @@ _git_config ()\n \tesac\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--system --global --local --file=\n-\t\t\t--list --replace-all\n-\t\t\t--get --get-all --get-regexp\n-\t\t\t--add --unset --unset-all\n-\t\t\t--remove-section --rename-section\n-\t\t\t--name-only\n-\t\t\t\"\n+\t\t__gitcomp_builtin config\n \t\treturn\n \t\t;;\n \tbranch.*.*)\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338834","messageId":"20180209110221.27224-16-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 15/42] completion: use __gitcomp_builtin in _git_describe","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:54Z","receivedAt":"2018-02-09T11:04:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6e17caf8d7..7a98f01067 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1369,11 +1369,7 @@ _git_describe ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--all --tags --contains --abbrev= --candidates=\n-\t\t\t--exact-match --debug --long --match --always --first-parent\n-\t\t\t--exclude --dirty --broken\n-\t\t\t\"\n+\t\t__gitcomp_builtin describe\n \t\treturn\n \tesac\n \t__git_complete_refs\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338835","messageId":"20180209110221.27224-17-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 16/42] completion: use __gitcomp_builtin in _git_difftool","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:55Z","receivedAt":"2018-02-09T11:04:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Since we can't automatically extract diff options for completion yet,\ndifftool will take all options from $__git_diff_common_options. This\nbrings _a lot_ more completable options to difftool.\n\n--ignore-submodules is added to $__git_diff_common_options to avoid\nregression in difftool. But it's a good thing anyway even for other\ndiff commands.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7a98f01067..7763f88347 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1394,7 +1394,7 @@ __git_diff_common_options=\"--stat --numstat --shortstat --summary\n \t\t\t--dirstat --dirstat= --dirstat-by-file\n \t\t\t--dirstat-by-file= --cumulative\n \t\t\t--diff-algorithm=\n-\t\t\t--submodule --submodule=\n+\t\t\t--submodule --submodule= --ignore-submodules\n \"\n \n _git_diff ()\n@@ -1435,11 +1435,11 @@ _git_difftool ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"--cached --staged --pickaxe-all --pickaxe-regex\n-\t\t\t--base --ours --theirs\n-\t\t\t--no-renames --diff-filter= --find-copies-harder\n-\t\t\t--relative --ignore-submodules\n-\t\t\t--tool=\"\n+\t\t__gitcomp_builtin difftool \"$__git_diff_common_options\n+\t\t\t\t\t--base --cached --ours --theirs\n+\t\t\t\t\t--pickaxe-all --pickaxe-regex\n+\t\t\t\t\t--relative --staged\n+\t\t\t\t\t\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338836","messageId":"20180209110221.27224-18-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 17/42] completion: use __gitcomp_builtin in _git_fetch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:56Z","receivedAt":"2018-02-09T11:04:13Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"New completable options:\n\n--deepen=\n--ipv4\n--ipv6\n--jobs=\n--multiple\n--progress\n--refmap=\n--shallow-exclude=\n--shallow-since=\n--update-head-ok\n\nSince _git_pull() needs fetch options too, $__git_fetch_options\nremains. This variable will soon be gone after _git_pull() is updated.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7763f88347..4275307c3d 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1462,7 +1462,7 @@ _git_fetch ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"$__git_fetch_options\"\n+\t\t__gitcomp_builtin fetch \"--no-tags\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338837","messageId":"20180209110221.27224-19-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 18/42] completion: use __gitcomp_builtin in _git_fsck","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:57Z","receivedAt":"2018-02-09T11:04:18Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--connectivity-only\n--dangling\n--progress\n--reflogs\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 4275307c3d..340e2414ff 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1499,10 +1499,7 @@ _git_fsck ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--tags --root --unreachable --cache --no-reflogs --full\n-\t\t\t--strict --verbose --lost-found --name-objects\n-\t\t\t\"\n+\t\t__gitcomp_builtin fsck \"--no-reflogs\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338838","messageId":"20180209110221.27224-20-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 19/42] completion: use __gitcomp_builtin in _git_gc","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:58Z","receivedAt":"2018-02-09T11:04:29Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --quiet.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/gc.c                           | 7 +++++--\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 3c5eae0edf..7fc5c16254 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -360,8 +360,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"prune unreferenced objects\"),\n \t\t\tPARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },\n \t\tOPT_BOOL(0, \"aggressive\", &aggressive, N_(\"be more thorough (increased runtime)\")),\n-\t\tOPT_BOOL(0, \"auto\", &auto_gc, N_(\"enable auto-gc mode\")),\n-\t\tOPT_BOOL(0, \"force\", &force, N_(\"force running gc even if there may be another gc running\")),\n+\t\tOPT_BOOL_F(0, \"auto\", &auto_gc, N_(\"enable auto-gc mode\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n+\t\tOPT_BOOL_F(0, \"force\", &force,\n+\t\t\t   N_(\"force running gc even if there may be another gc running\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_END()\n \t};\n \ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 340e2414ff..79e9f69d52 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1509,7 +1509,7 @@ _git_gc ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--prune --aggressive\"\n+\t\t__gitcomp_builtin gc\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338839","messageId":"20180209110221.27224-21-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 20/42] completion: use __gitcomp_builtin in _git_grep","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:01:59Z","receivedAt":"2018-02-09T11:04:32Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--after-context=\n--before-context=\n--color\n--context\n--exclude-standard\n--quiet\n--recurse-submodules\n--textconv\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/grep.c                         | 13 ++++++++-----\n contrib/completion/git-completion.bash | 16 +---------------\n 2 files changed, 9 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ca4ac80d8..496f33336e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -832,8 +832,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL('L', \"files-without-match\",\n \t\t\t&opt.unmatch_name_only,\n \t\t\tN_(\"show only the names of files without match\")),\n-\t\tOPT_BOOL('z', \"null\", &opt.null_following_name,\n-\t\t\tN_(\"print NUL after filenames\")),\n+\t\tOPT_BOOL_F('z', \"null\", &opt.null_following_name,\n+\t\t\t   N_(\"print NUL after filenames\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('c', \"count\", &opt.count,\n \t\t\tN_(\"show the number of matches instead of matching lines\")),\n \t\tOPT__COLOR(&opt.color, N_(\"highlight matches\")),\n@@ -884,9 +885,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_GROUP(\"\"),\n \t\t{ OPTION_STRING, 'O', \"open-files-in-pager\", &show_in_pager,\n \t\t\tN_(\"pager\"), N_(\"show matching files in the pager\"),\n-\t\t\tPARSE_OPT_OPTARG, NULL, (intptr_t)default_pager },\n-\t\tOPT_BOOL(0, \"ext-grep\", &external_grep_allowed__ignored,\n-\t\t\t N_(\"allow calling of grep(1) (ignored by this build)\")),\n+\t\t\tPARSE_OPT_OPTARG | PARSE_OPT_NOCOMPLETE,\n+\t\t\tNULL, (intptr_t)default_pager },\n+\t\tOPT_BOOL_F(0, \"ext-grep\", &external_grep_allowed__ignored,\n+\t\t\t   N_(\"allow calling of grep(1) (ignored by this build)\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_END()\n \t};\n \ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 79e9f69d52..60d27253ee 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1565,21 +1565,7 @@ _git_grep ()\n \n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--cached\n-\t\t\t--text --ignore-case --word-regexp --invert-match\n-\t\t\t--full-name --line-number\n-\t\t\t--extended-regexp --basic-regexp --fixed-strings\n-\t\t\t--perl-regexp\n-\t\t\t--threads\n-\t\t\t--files-with-matches --name-only\n-\t\t\t--files-without-match\n-\t\t\t--max-depth\n-\t\t\t--count\n-\t\t\t--and --or --not --all-match\n-\t\t\t--break --heading --show-function --function-context\n-\t\t\t--untracked --no-index\n-\t\t\t\"\n+\t\t__gitcomp_builtin grep\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338841","messageId":"20180209110221.27224-22-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 21/42] completion: use __gitcomp_builtin in _git_help","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:00Z","receivedAt":"2018-02-09T11:04:36Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 60d27253ee..08f024a0ba 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1583,7 +1583,7 @@ _git_help ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--all --guides --info --man --web\"\n+\t\t__gitcomp_builtin help\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338842","messageId":"20180209110221.27224-23-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 22/42] completion: use __gitcomp_builtin in _git_init","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:01Z","receivedAt":"2018-02-09T11:04:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --separate-git-dir=.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 08f024a0ba..36ed502ed0 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1606,7 +1606,7 @@ _git_init ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"--quiet --bare --template= --shared --shared=\"\n+\t\t__gitcomp_builtin init\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338843","messageId":"20180209110221.27224-24-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 23/42] completion: use __gitcomp_builtin in _git_ls_files","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:02Z","receivedAt":"2018-02-09T11:04:47Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--debug\n--empty-directory\n--eol\n--recurse-submodules\n--resolve-undo\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 8 +-------\n 1 file changed, 1 insertion(+), 7 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 36ed502ed0..1ea06b6e17 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1616,13 +1616,7 @@ _git_ls_files ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--cached --deleted --modified --others --ignored\n-\t\t\t--stage --directory --no-empty-directory --unmerged\n-\t\t\t--killed --exclude= --exclude-from=\n-\t\t\t--exclude-per-directory= --exclude-standard\n-\t\t\t--error-unmatch --with-tree= --full-name\n-\t\t\t--abbrev --ignored --exclude-per-directory\n-\t\t\t\"\n+\t\t__gitcomp_builtin ls-files \"--no-empty-directory\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338844","messageId":"20180209110221.27224-26-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 25/42] completion: use __gitcomp_builtin in _git_merge","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:04Z","receivedAt":"2018-02-09T11:05:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"New completable options are:\n\n--allow-unrelated-histories\n--message=\n--overwrite-ignore\n--signoff\n--strategy-option=\n--summary\n--verify\n\nThe variable $__git_merge_options remains because _git_pull() still\nneeds it. It will soon be gone after _git_pull() is updated.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e22ea60bc8..4f598820cd 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1768,8 +1768,13 @@ _git_merge ()\n \n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"$__git_merge_options\n-\t\t\t--rerere-autoupdate --no-rerere-autoupdate --abort --continue\"\n+\t\t__gitcomp_builtin merge \"--rerere-autoupdate\n+\t\t\t\t--no-rerere-autoupdate\n+\t\t\t\t--no-commit --no-edit --no-ff\n+\t\t\t\t--no-log --no-progress\n+\t\t\t\t--no-squash --no-stat\n+\t\t\t\t--no-verify-signatures\n+\t\t\t\t\"\n \t\treturn\n \tesac\n \t__git_complete_refs\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338845","messageId":"20180209110221.27224-27-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 26/42] completion: use __gitcomp_builtin in _git_merge_base","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:05Z","receivedAt":"2018-02-09T11:05:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completion option is --all.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 4f598820cd..b192a5c0a1 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1798,7 +1798,7 @@ _git_merge_base ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--octopus --independent --is-ancestor --fork-point\"\n+\t\t__gitcomp_builtin merge-base\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338846","messageId":"20180209110221.27224-28-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 27/42] completion: use __gitcomp_builtin in _git_mv","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:06Z","receivedAt":"2018-02-09T11:05:12Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --verbose.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/mv.c                           | 3 ++-\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex b88023a733..e3e308d282 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -122,7 +122,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \tstruct option builtin_mv_options[] = {\n \t\tOPT__VERBOSE(&verbose, N_(\"be verbose\")),\n \t\tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n-\t\tOPT__FORCE(&force, N_(\"force move/rename even if target exists\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"force move/rename even if target exists\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL('k', NULL, &ignore_errors, N_(\"skip move/rename errors\")),\n \t\tOPT_END(),\n \t};\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex b192a5c0a1..bbf8623e3a 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1809,7 +1809,7 @@ _git_mv ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--dry-run\"\n+\t\t__gitcomp_builtin mv\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338847","messageId":"20180209110221.27224-29-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 28/42] completion: use __gitcomp_builtin in _git_name_rev","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:07Z","receivedAt":"2018-02-09T11:05:14Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--always\n--exclude\n--name-only\n--refs\n--undefined\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex bbf8623e3a..c7b8b37f19 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1825,7 +1825,7 @@ _git_mv ()\n \n _git_name_rev ()\n {\n-\t__gitcomp \"--tags --all --stdin\"\n+\t__gitcomp_builtin name-rev\n }\n \n _git_notes ()\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338848","messageId":"20180209110221.27224-25-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 24/42] completion: use __gitcomp_builtin in _git_ls_remote","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:03Z","receivedAt":"2018-02-09T11:05:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are --quiet and --upload-pack=.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/ls-remote.c                    | 5 +++--\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex c4be98ab9e..540d56429f 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -60,8 +60,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\tOPT_BIT(0, \"refs\", &flags, N_(\"do not show peeled tags\"), REF_NORMAL),\n \t\tOPT_BOOL(0, \"get-url\", &get_url,\n \t\t\t N_(\"take url.<base>.insteadOf into account\")),\n-\t\tOPT_SET_INT(0, \"exit-code\", &status,\n-\t\t\t    N_(\"exit with exit code 2 if no matching refs are found\"), 2),\n+\t\tOPT_SET_INT_F(0, \"exit-code\", &status,\n+\t\t\t      N_(\"exit with exit code 2 if no matching refs are found\"),\n+\t\t\t      2, PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"symref\", &show_symref_target,\n \t\t\t N_(\"show underlying ref in addition to the object pointed by it\")),\n \t\tOPT_END()\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1ea06b6e17..e22ea60bc8 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1630,7 +1630,7 @@ _git_ls_remote ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--heads --tags --refs --get-url --symref\"\n+\t\t__gitcomp_builtin ls-remote\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338849","messageId":"20180209110221.27224-30-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 29/42] completion: use __gitcomp_builtin in _git_notes","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:08Z","receivedAt":"2018-02-09T11:05:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--allow-empty (notes add and notes append)\n--for-rewrite= (notes copy)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/notes.c                        |  4 ++--\n contrib/completion/git-completion.bash | 14 ++++++++------\n 2 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex b52e71c73e..6990683bd4 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -413,7 +413,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\tparse_reuse_arg},\n \t\tOPT_BOOL(0, \"allow-empty\", &allow_empty,\n \t\t\tN_(\"allow storing empty note\")),\n-\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_END()\n \t};\n \n@@ -484,7 +484,7 @@ static int copy(int argc, const char **argv, const char *prefix)\n \tstruct notes_tree *t;\n \tconst char *rewrite_cmd = NULL;\n \tstruct option options[] = {\n-\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), 0),\n+\t\tOPT__FORCE(&force, N_(\"replace existing notes\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"stdin\", &from_stdin, N_(\"read objects from stdin\")),\n \t\tOPT_STRING(0, \"for-rewrite\", &rewrite_cmd, N_(\"command\"),\n \t\t\t   N_(\"load rewriting config for <command> (implies \"\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex c7b8b37f19..60127daebf 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1835,7 +1835,7 @@ _git_notes ()\n \n \tcase \"$subcommand,$cur\" in\n \t,--*)\n-\t\t__gitcomp '--ref'\n+\t\t__gitcomp_builtin notes\n \t\t;;\n \t,*)\n \t\tcase \"$prev\" in\n@@ -1851,15 +1851,17 @@ _git_notes ()\n \tadd,--reedit-message=*|append,--reedit-message=*)\n \t\t__git_complete_refs --cur=\"${cur#*=}\"\n \t\t;;\n-\tadd,--*|append,--*)\n-\t\t__gitcomp '--file= --message= --reedit-message=\n-\t\t\t\t--reuse-message='\n+\tadd,--*)\n+\t\t__gitcomp_builtin notes_add\n+\t\t;;\n+\tappend,--*)\n+\t\t__gitcomp_builtin notes_append\n \t\t;;\n \tcopy,--*)\n-\t\t__gitcomp '--stdin'\n+\t\t__gitcomp_builtin notes_copy\n \t\t;;\n \tprune,--*)\n-\t\t__gitcomp '--dry-run --verbose'\n+\t\t__gitcomp_builtin notes_prune\n \t\t;;\n \tprune,*)\n \t\t;;\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338850","messageId":"20180209110221.27224-31-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 30/42] completion: use __gitcomp_builtin in _git_pull","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:09Z","receivedAt":"2018-02-09T11:05:24Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This is really nice. Since pull_options[] already declares all\npassthru options to 'merge' or 'fetch', a single\n\n    git pull --git-completion-helper\n\nwould provide all completable options (--no- variants are a separate\nissue). Dead shell variables can now be deleted.\n\nNew completable options are:\n\n--allow-unrelated-histories\n--ipv4\n--ipv6\n--jobs\n--refmap=\n--signoff\n--strategy-option=\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 25 +++++--------------------\n 1 file changed, 5 insertions(+), 20 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 60127daebf..697fca0c4b 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1448,12 +1448,6 @@ _git_difftool ()\n \n __git_fetch_recurse_submodules=\"yes on-demand no\"\n \n-__git_fetch_options=\"\n-\t--quiet --verbose --append --upload-pack --force --keep --depth=\n-\t--tags --no-tags --all --prune --dry-run --recurse-submodules=\n-\t--unshallow --update-shallow\n-\"\n-\n _git_fetch ()\n {\n \tcase \"$cur\" in\n@@ -1754,14 +1748,6 @@ _git_log ()\n \t__git_complete_revlist\n }\n \n-# Common merge options shared by git-merge(1) and git-pull(1).\n-__git_merge_options=\"\n-\t--no-commit --no-stat --log --no-log --squash --strategy\n-\t--commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit\n-\t--verify-signatures --no-verify-signatures --gpg-sign\n-\t--quiet --verbose --progress --no-progress\n-\"\n-\n _git_merge ()\n {\n \t__git_complete_strategy && return\n@@ -1887,12 +1873,11 @@ _git_pull ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--rebase --no-rebase\n-\t\t\t--autostash --no-autostash\n-\t\t\t$__git_merge_options\n-\t\t\t$__git_fetch_options\n-\t\t\"\n+\t\t__gitcomp_builtin pull \"--no-autostash --no-commit --no-edit\n+\t\t\t\t\t--no-ff --no-log --no-progress --no-rebase\n+\t\t\t\t\t--no-squash --no-stat --no-tags\n+\t\t\t\t\t--no-verify-signatures\"\n+\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338851","messageId":"20180209110221.27224-32-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 31/42] completion: use __gitcomp_builtin in _git_push","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:10Z","receivedAt":"2018-02-09T11:05:28Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--atomic\n--exec=\n--ipv4\n--ipv6\n--no-verify\n--porcelain\n--progress\n--push-option\n--signed\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/push.c                         | 2 +-\n contrib/completion/git-completion.bash | 7 +------\n 2 files changed, 2 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/push.c b/builtin/push.c\nindex 1c28427d82..013c20d616 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -548,7 +548,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_CALLBACK, 0, \"recurse-submodules\", &recurse_submodules, \"check|on-demand|no\",\n \t\t\tN_(\"control recursive pushing of submodules\"),\n \t\t\tPARSE_OPT_OPTARG, option_parse_recurse_submodules },\n-\t\tOPT_BOOL( 0 , \"thin\", &thin, N_(\"use thin pack\")),\n+\t\tOPT_BOOL_F( 0 , \"thin\", &thin, N_(\"use thin pack\"), PARSE_OPT_NOCOMPLETE),\n \t\tOPT_STRING( 0 , \"receive-pack\", &receivepack, \"receive-pack\", N_(\"receive pack program\")),\n \t\tOPT_STRING( 0 , \"exec\", &receivepack, \"receive-pack\", N_(\"receive pack program\")),\n \t\tOPT_BIT('u', \"set-upstream\", &flags, N_(\"set upstream for git pull/status\"),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 697fca0c4b..d8d9e8f0de 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1928,12 +1928,7 @@ _git_push ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--all --mirror --tags --dry-run --force --verbose\n-\t\t\t--quiet --prune --delete --follow-tags\n-\t\t\t--receive-pack= --repo= --set-upstream\n-\t\t\t--force-with-lease --force-with-lease= --recurse-submodules=\n-\t\t\"\n+\t\t__gitcomp_builtin push\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338852","messageId":"20180209110221.27224-33-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 32/42] completion: use __gitcomp_builtin in _git_remote","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:11Z","receivedAt":"2018-02-09T11:05:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex d8d9e8f0de..6e600b7aa3 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2612,7 +2612,7 @@ _git_remote ()\n \tif [ -z \"$subcommand\" ]; then\n \t\tcase \"$cur\" in\n \t\t--*)\n-\t\t\t__gitcomp \"--verbose\"\n+\t\t\t__gitcomp_builtin remote\n \t\t\t;;\n \t\t*)\n \t\t\t__gitcomp \"$subcommands\"\n@@ -2623,33 +2623,33 @@ _git_remote ()\n \n \tcase \"$subcommand,$cur\" in\n \tadd,--*)\n-\t\t__gitcomp \"--track --master --fetch --tags --no-tags --mirror=\"\n+\t\t__gitcomp_builtin remote_add \"--no-tags\"\n \t\t;;\n \tadd,*)\n \t\t;;\n \tset-head,--*)\n-\t\t__gitcomp \"--auto --delete\"\n+\t\t__gitcomp_builtin remote_set-head\n \t\t;;\n \tset-branches,--*)\n-\t\t__gitcomp \"--add\"\n+\t\t__gitcomp_builtin remote_set-branches\n \t\t;;\n \tset-head,*|set-branches,*)\n \t\t__git_complete_remote_or_refspec\n \t\t;;\n \tupdate,--*)\n-\t\t__gitcomp \"--prune\"\n+\t\t__gitcomp_builtin remote_update\n \t\t;;\n \tupdate,*)\n \t\t__gitcomp \"$(__git_get_config_variables \"remotes\")\"\n \t\t;;\n \tset-url,--*)\n-\t\t__gitcomp \"--push --add --delete\"\n+\t\t__gitcomp_builtin remote_set-url\n \t\t;;\n \tget-url,--*)\n-\t\t__gitcomp \"--push --all\"\n+\t\t__gitcomp_builtin remote_get-url\n \t\t;;\n \tprune,--*)\n-\t\t__gitcomp \"--dry-run\"\n+\t\t__gitcomp_builtin remote_prune\n \t\t;;\n \t*)\n \t\t__gitcomp_nl \"$(__git_remotes)\"\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338853","messageId":"20180209110221.27224-34-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 33/42] remote: force completing --mirror= instead of --mirror","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:12Z","receivedAt":"2018-02-09T11:05:38Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"git remote --mirror\" is a special case. Technically it is possible to\nspecify --mirror without any argument. But we will get a \"dangerous,\ndeprecated!\" warning in that case.\n\nThis new parse-opt flag allows --git-completion-helper to always\ncomplete --mirror=, ignoring the dangerous use case.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/remote.c | 2 +-\n parse-options.c  | 2 ++\n parse-options.h  | 6 +++++-\n 3 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex d95bf904c3..fce9e5c0f6 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -168,7 +168,7 @@ static int add(int argc, const char **argv)\n \t\tOPT_STRING('m', \"master\", &master, N_(\"branch\"), N_(\"master branch\")),\n \t\t{ OPTION_CALLBACK, 0, \"mirror\", &mirror, N_(\"push|fetch\"),\n \t\t\tN_(\"set up remote as a mirror to push to or fetch from\"),\n-\t\t\tPARSE_OPT_OPTARG, parse_mirror_opt },\n+\t\t\tPARSE_OPT_OPTARG | PARSE_OPT_COMP_ARG, parse_mirror_opt },\n \t\tOPT_END()\n \t};\n \ndiff --git a/parse-options.c b/parse-options.c\nindex 29f4defdd6..979577ba2c 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -459,6 +459,8 @@ static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n \t\tdefault:\n \t\t\tbreak;\n \t\t}\n+\t\tif (opts->flags & PARSE_OPT_COMP_ARG)\n+\t\t\tsuffix = \"=\";\n \t\tprintf(\" --%s%s\", opts->long_name, suffix);\n \t}\n \tfputc('\\n', stdout);\ndiff --git a/parse-options.h b/parse-options.h\nindex 009cd863e5..0ba08691e6 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -39,7 +39,8 @@ enum parse_opt_option_flags {\n \tPARSE_OPT_NODASH = 32,\n \tPARSE_OPT_LITERAL_ARGHELP = 64,\n \tPARSE_OPT_SHELL_EVAL = 256,\n-\tPARSE_OPT_NOCOMPLETE = 512\n+\tPARSE_OPT_NOCOMPLETE = 512,\n+\tPARSE_OPT_COMP_ARG = 1024\n };\n \n struct option;\n@@ -92,6 +93,9 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n  *\t\t\t\tUseful for options with multiple parameters.\n  *   PARSE_OPT_NOCOMPLETE: by default all visible options are completable\n  *\t\t\t   by git-completion.bash. This option suppresses that.\n+ *   PARSE_OPT_COMP_ARG: this option forces to git-completion.bash to\n+ *\t\t\t complete an option as --name= not --name even if\n+ *\t\t\t the option takes optional argument.\n  *\n  * `callback`::\n  *   pointer to the callback to use for OPTION_CALLBACK or\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338854","messageId":"20180209110221.27224-35-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 34/42] completion: use __gitcomp_builtin in _git_replace","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:13Z","receivedAt":"2018-02-09T11:05:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --raw.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/replace.c                      | 3 ++-\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 10078ae371..0c1d8e1b08 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -439,7 +439,8 @@ int cmd_replace(int argc, const char **argv, const char *prefix)\n \t\tOPT_CMDMODE('d', \"delete\", &cmdmode, N_(\"delete replace refs\"), MODE_DELETE),\n \t\tOPT_CMDMODE('e', \"edit\", &cmdmode, N_(\"edit existing object\"), MODE_EDIT),\n \t\tOPT_CMDMODE('g', \"graft\", &cmdmode, N_(\"change a commit's parents\"), MODE_GRAFT),\n-\t\tOPT_BOOL('f', \"force\", &force, N_(\"replace the ref if it exists\")),\n+\t\tOPT_BOOL_F('f', \"force\", &force, N_(\"replace the ref if it exists\"),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"raw\", &raw, N_(\"do not pretty-print contents for --edit\")),\n \t\tOPT_STRING(0, \"format\", &format, N_(\"format\"), N_(\"use this format\")),\n \t\tOPT_END()\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6e600b7aa3..18c2ccece9 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2661,7 +2661,7 @@ _git_replace ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--edit --graft --format= --list --delete\"\n+\t\t__gitcomp_builtin replace\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338855","messageId":"20180209110221.27224-36-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 35/42] completion: use __gitcomp_builtin in _git_reset","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:14Z","receivedAt":"2018-02-09T11:05:48Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--intent-to-add\n--quiet\n--recurse-submodules\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 18c2ccece9..9aca05d01e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2685,7 +2685,7 @@ _git_reset ()\n \n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--merge --mixed --hard --soft --patch --keep\"\n+\t\t__gitcomp_builtin reset\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338856","messageId":"20180209110221.27224-37-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 36/42] completion: use __gitcomp_builtin in _git_revert","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:15Z","receivedAt":"2018-02-09T11:05:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable option is --gpg-sign\n\nIn-progress options like --continue will be part of --git-completion-helper\nthen filtered out by _git_revert() unless the operation is in\nprogress. This helps keep marking of these operations in just one place.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9aca05d01e..e63f2f2741 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2692,19 +2692,19 @@ _git_reset ()\n \t__git_complete_refs\n }\n \n+__git_revert_inprogress_options=\"--continue --quit --abort\"\n+\n _git_revert ()\n {\n \t__git_find_repo_path\n \tif [ -f \"$__git_repo_path\"/REVERT_HEAD ]; then\n-\t\t__gitcomp \"--continue --quit --abort\"\n+\t\t__gitcomp \"$__git_revert_inprogress_options\"\n \t\treturn\n \tfi\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--edit --mainline --no-edit --no-commit --signoff\n-\t\t\t--strategy= --strategy-option=\n-\t\t\t\"\n+\t\t__gitcomp_builtin revert \"--no-edit\" \\\n+\t\t\t\"$__git_revert_inprogress_options\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338857","messageId":"20180209110221.27224-38-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 37/42] completion: use __gitcomp_builtin in _git_rm","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:16Z","receivedAt":"2018-02-09T11:05:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/rm.c                           | 2 +-\n contrib/completion/git-completion.bash | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 6e0c7f5ac6..a818efe230 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -242,7 +242,7 @@ static struct option builtin_rm_options[] = {\n \tOPT__DRY_RUN(&show_only, N_(\"dry run\")),\n \tOPT__QUIET(&quiet, N_(\"do not list removed files\")),\n \tOPT_BOOL( 0 , \"cached\",         &index_only, N_(\"only remove from the index\")),\n-\tOPT__FORCE(&force, N_(\"override the up-to-date check\"), 0),\n+\tOPT__FORCE(&force, N_(\"override the up-to-date check\"), PARSE_OPT_NOCOMPLETE),\n \tOPT_BOOL('r', NULL,             &recursive,  N_(\"allow recursive removal\")),\n \tOPT_BOOL( 0 , \"ignore-unmatch\", &ignore_unmatch,\n \t\t\t\tN_(\"exit with a zero status even if nothing matched\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e63f2f2741..30a51c5015 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2715,7 +2715,7 @@ _git_rm ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"--cached --dry-run --ignore-unmatch --quiet\"\n+\t\t__gitcomp_builtin rm\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338858","messageId":"20180209110221.27224-39-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 38/42] completion: use __gitcomp_builtin in _git_show_branch","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:17Z","receivedAt":"2018-02-09T11:06:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"No new completable options!\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 30a51c5015..7d58969efb 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2773,12 +2773,7 @@ _git_show_branch ()\n {\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--all --remotes --topo-order --date-order --current --more=\n-\t\t\t--list --independent --merge-base --no-name\n-\t\t\t--color --no-color\n-\t\t\t--sha1-name --sparse --topics --reflog\n-\t\t\t\"\n+\t\t__gitcomp_builtin show-branch \"--no-color\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338859","messageId":"20180209110221.27224-40-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 39/42] completion: use __gitcomp_builtin in _git_status","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:18Z","receivedAt":"2018-02-09T11:06:09Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are --null and --show-stash.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7d58969efb..7724ce7808 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2066,11 +2066,7 @@ _git_status ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--short --branch --porcelain --long --verbose\n-\t\t\t--untracked-files= --ignore-submodules= --ignored\n-\t\t\t--column= --no-column\n-\t\t\t\"\n+\t\t__gitcomp_builtin status \"--no-column\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338860","messageId":"20180209110221.27224-41-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 40/42] completion: use __gitcomp_builtin in _git_tag","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:19Z","receivedAt":"2018-02-09T11:06:15Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options are:\n\n--color\n--format=\n--ignore-case\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7724ce7808..e76b2f0356 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -3002,11 +3002,7 @@ _git_tag ()\n \n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--list --delete --verify --annotate --message --file\n-\t\t\t--sign --cleanup --local-user --force --column --sort=\n-\t\t\t--contains --no-contains --points-at --merged --no-merged --create-reflog\n-\t\t\t\"\n+\t\t__gitcomp_builtin tag\n \t\t;;\n \tesac\n }\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338861","messageId":"20180209110221.27224-42-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 41/42] completion: use __gitcomp_builtin in _git_worktree","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:20Z","receivedAt":"2018-02-09T11:06:20Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The new completable options for \"worktree add\" are:\n\n--checkout\n--guess-remote\n--lock\n--track\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/worktree.c                     | 2 +-\n contrib/completion/git-completion.bash | 8 ++++----\n 2 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 4d3422f62e..76dc6b8cb5 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -367,7 +367,7 @@ static int add(int ac, const char **av, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__FORCE(&opts.force,\n \t\t\t   N_(\"checkout <branch> even if already checked out in other worktree\"),\n-\t\t\t   0),\n+\t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_STRING('b', NULL, &opts.new_branch, N_(\"branch\"),\n \t\t\t   N_(\"create a new branch\")),\n \t\tOPT_STRING('B', NULL, &new_branch_force, N_(\"branch\"),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e76b2f0356..0ddf40063b 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -3021,16 +3021,16 @@ _git_worktree ()\n \telse\n \t\tcase \"$subcommand,$cur\" in\n \t\tadd,--*)\n-\t\t\t__gitcomp \"--detach\"\n+\t\t\t__gitcomp_builtin worktree_add\n \t\t\t;;\n \t\tlist,--*)\n-\t\t\t__gitcomp \"--porcelain\"\n+\t\t\t__gitcomp_builtin worktree_list\n \t\t\t;;\n \t\tlock,--*)\n-\t\t\t__gitcomp \"--reason\"\n+\t\t\t__gitcomp_builtin worktree_lock\n \t\t\t;;\n \t\tprune,--*)\n-\t\t\t__gitcomp \"--dry-run --expire --verbose\"\n+\t\t\t__gitcomp_builtin worktree_prune\n \t\t\t;;\n \t\t*)\n \t\t\t;;\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338862","messageId":"20180209110221.27224-43-pclouds@gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-1-pclouds@gmail.com","subject":"[PATCH v3 42/42] git-completion.bash: add GIT_COMPLETION_OPTIONS=all config","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-09T11:02:21Z","receivedAt":"2018-02-09T11:06:25Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"By default, some option names (mostly --force, scripting related or for\ninternal use) are not completable for various reasons. When\nGIT_COMPLETION_OPTIONS is set to all, all options (except hidden ones)\nare completable.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n contrib/completion/git-completion.bash |  6 +++++-\n parse-options.c                        | 11 +++++++----\n 2 files changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0ddf40063b..0cfa489a8e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -36,6 +36,10 @@\n #\n #     When set to \"1\", do not include \"DWIM\" suggestions in git-checkout\n #     completion (e.g., completing \"foo\" when \"origin/foo\" exists).\n+#\n+#   GIT_COMPLETION_OPTIONS\n+#\n+#     When set to \"all\", complete all possible options\n \n case \"$COMP_WORDBREAKS\" in\n *:*) : great ;;\n@@ -303,7 +307,7 @@ __gitcomp_builtin ()\n \tif [ -z \"$options\" ]; then\n \t\t# leading and trailing spaces are significant to make\n \t\t# option removal work correctly.\n-\t\toptions=\" $(__git ${cmd/_/ } --git-completion-helper) $incl \"\n+\t\toptions=\" $(__git ${cmd/_/ } --git-completion-helper=$GIT_COMPLETION_OPTIONS) $incl \"\n \t\tfor i in $excl; do\n \t\t\toptions=\"${options/ $i / }\"\n \t\tdone\ndiff --git a/parse-options.c b/parse-options.c\nindex 979577ba2c..5b8b2b376e 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -430,14 +430,17 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,\n  * many options that do not suppress it properly.\n  */\n static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n-\t\t\tconst struct option *opts)\n+\t\t\tconst struct option *opts,\n+\t\t\tconst char *arg)\n {\n \tfor (; opts->type != OPTION_END; opts++) {\n \t\tconst char *suffix = \"\";\n \n \t\tif (!opts->long_name)\n \t\t\tcontinue;\n-\t\tif (opts->flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE))\n+\t\tif (opts->flags & PARSE_OPT_HIDDEN)\n+\t\t\tcontinue;\n+\t\tif ((opts->flags & PARSE_OPT_NOCOMPLETE) && strcmp(arg, \"all\"))\n \t\t\tcontinue;\n \n \t\tswitch (opts->type) {\n@@ -498,8 +501,8 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,\n \t\t\tgoto show_usage;\n \n \t\t/* lone --git-completion-helper is asked by git-completion.bash */\n-\t\tif (ctx->total == 1 && !strcmp(arg + 1, \"-git-completion-helper\"))\n-\t\t\treturn show_gitcomp(ctx, options);\n+\t\tif (ctx->total == 1 && skip_prefix(arg + 1, \"-git-completion-helper=\", &arg))\n+\t\t\treturn show_gitcomp(ctx, options, arg);\n \n \t\tif (arg[1] != '-') {\n \t\t\tctx->opt = arg + 1;\n-- \n2.16.1.207.gedba492059\n\n"},{"id":"338879","messageId":"877ermmeia.fsf@evledraar.gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-43-pclouds@gmail.com","subject":"Re: [PATCH v3 42/42] git-completion.bash: add GIT_COMPLETION_OPTIONS=all config","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-02-09T14:19:57Z","receivedAt":"2018-02-09T14:20:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Feb 09 2018, Nguyễn Thái Ngọc Duy jotted:\n\n> By default, some option names (mostly --force, scripting related or for\n> internal use) are not completable for various reasons. When\n> GIT_COMPLETION_OPTIONS is set to all, all options (except hidden ones)\n> are completable.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash |  6 +++++-\n>  parse-options.c                        | 11 +++++++----\n>  2 files changed, 12 insertions(+), 5 deletions(-)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 0ddf40063b..0cfa489a8e 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -36,6 +36,10 @@\n>  #\n>  #     When set to \"1\", do not include \"DWIM\" suggestions in git-checkout\n>  #     completion (e.g., completing \"foo\" when \"origin/foo\" exists).\n> +#\n> +#   GIT_COMPLETION_OPTIONS\n> +#\n> +#     When set to \"all\", complete all possible options\n\nI was going to suggest some wording like:\n\n    When set to \"all\", include options considered unsafe such as --force\n    in the completion.\n\nHowever per your cover letter it's not just used for that:\n\n     10 --force\n      4 --rerere-autoupdate\n      1 --unsafe-paths\n      1 --thin\n      1 --overwrite-ignore\n      1 --open-files-in-pager\n      1 --null\n      1 --ext-grep\n      1 --exit-code\n      1 --auto\n\nI wonder if we shouldn't just make this only about --force, I don't see\nwhy \"git grep --o<TAB>\" should only show --or but not\n--open-files-in-pager, and e.g. \"git grep --<TAB>\" is already verbose so\nwe're not saving much by excluding those.\n\nThen this could just become:\n\n    GIT_COMPLETION_SHOWUNSAFEOPTIONS=1\n\nOr other similar boolean variable, for consistency with all the \"*SHOW*\nvariables already in git-completion.bash.\n\n>  case \"$COMP_WORDBREAKS\" in\n>  *:*) : great ;;\n> @@ -303,7 +307,7 @@ __gitcomp_builtin ()\n>  \tif [ -z \"$options\" ]; then\n>  \t\t# leading and trailing spaces are significant to make\n>  \t\t# option removal work correctly.\n> -\t\toptions=\" $(__git ${cmd/_/ } --git-completion-helper) $incl \"\n> +\t\toptions=\" $(__git ${cmd/_/ } --git-completion-helper=$GIT_COMPLETION_OPTIONS) $incl \"\n>  \t\tfor i in $excl; do\n>  \t\t\toptions=\"${options/ $i / }\"\n>  \t\tdone\n> diff --git a/parse-options.c b/parse-options.c\n> index 979577ba2c..5b8b2b376e 100644\n> --- a/parse-options.c\n> +++ b/parse-options.c\n> @@ -430,14 +430,17 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,\n>   * many options that do not suppress it properly.\n>   */\n>  static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n> -\t\t\tconst struct option *opts)\n> +\t\t\tconst struct option *opts,\n> +\t\t\tconst char *arg)\n>  {\n>  \tfor (; opts->type != OPTION_END; opts++) {\n>  \t\tconst char *suffix = \"\";\n>\n>  \t\tif (!opts->long_name)\n>  \t\t\tcontinue;\n> -\t\tif (opts->flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE))\n> +\t\tif (opts->flags & PARSE_OPT_HIDDEN)\n> +\t\t\tcontinue;\n> +\t\tif ((opts->flags & PARSE_OPT_NOCOMPLETE) && strcmp(arg, \"all\"))\n>  \t\t\tcontinue;\n>\n>  \t\tswitch (opts->type) {\n> @@ -498,8 +501,8 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,\n>  \t\t\tgoto show_usage;\n>\n>  \t\t/* lone --git-completion-helper is asked by git-completion.bash */\n> -\t\tif (ctx->total == 1 && !strcmp(arg + 1, \"-git-completion-helper\"))\n> -\t\t\treturn show_gitcomp(ctx, options);\n> +\t\tif (ctx->total == 1 && skip_prefix(arg + 1, \"-git-completion-helper=\", &arg))\n> +\t\t\treturn show_gitcomp(ctx, options, arg);\n>\n>  \t\tif (arg[1] != '-') {\n>  \t\t\tctx->opt = arg + 1;\n"},{"id":"338893","messageId":"xmqq1shuxa4h.fsf@gitster-ct.c.googlers.com","threadId":"47727","inReplyTo":"20180209110221.27224-5-pclouds@gmail.com","subject":"Re: [PATCH v3 04/42] git-completion.bash: introduce __gitcomp_builtin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-02-09T18:59:10Z","receivedAt":"2018-02-09T18:59:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> +# This function is equivalent to\n> +#\n> +#    __gitcomp \"$(git xxx --git-completion-helper) ...\"\n> +#\n> +# except that the output is cached. Accept 1-3 arguments:\n> +# 1: the git command to execute, this is also the cache key\n> +# 2: extra options to be added on top (e.g. negative forms)\n> +# 3: options to be excluded\n\nThe options=\"${options/ $i / }\" substitution in a loop is cute.  The\nthird argument to this helper is an IFS separated list of regular\nexpressions to match options that we do not want to see in the\ncompletion, so \n\n\t__gitcomp_builtin foo '' '--a[^ ]*'\n\npresumably would exclude all options whose names begin with 'a' ;-).\n\n> +\tif [ -z \"$options\" ]; then\n> +\t\t# leading and trailing spaces are significant to make\n> +\t\t# option removal work correctly.\n> +\t\toptions=\" $(__git ${cmd/_/ } --git-completion-helper) $incl \"\n> +\t\tfor i in $excl; do\n> +\t\t\toptions=\"${options/ $i / }\"\n> +\t\tdone\n> +\t\teval \"$var=\\\"$options\\\"\"\n> +\tfi\n> +\n> +\t__gitcomp \"$options\"\n> +}\n> +\n>  # Variation of __gitcomp_nl () that appends to the existing list of\n>  # completion candidates, COMPREPLY.\n>  __gitcomp_nl_append ()\n"},{"id":"338971","messageId":"20180210092945.GA6370@ash","threadId":"47727","inReplyTo":"877ermmeia.fsf@evledraar.gmail.com","subject":"Re: [PATCH v3 42/42] git-completion.bash: add GIT_COMPLETION_OPTIONS=all config","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-10T09:29:46Z","receivedAt":"2018-02-10T09:29:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 09, 2018 at 03:19:57PM +0100, Ævar Arnfjörð Bjarmason wrote:\n> \n> On Fri, Feb 09 2018, Nguyễn Thái Ngọc Duy jotted:\n> \n> > By default, some option names (mostly --force, scripting related or for\n> > internal use) are not completable for various reasons. When\n> > GIT_COMPLETION_OPTIONS is set to all, all options (except hidden ones)\n> > are completable.\n> >\n> > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> > ---\n> >  contrib/completion/git-completion.bash |  6 +++++-\n> >  parse-options.c                        | 11 +++++++----\n> >  2 files changed, 12 insertions(+), 5 deletions(-)\n> >\n> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> > index 0ddf40063b..0cfa489a8e 100644\n> > --- a/contrib/completion/git-completion.bash\n> > +++ b/contrib/completion/git-completion.bash\n> > @@ -36,6 +36,10 @@\n> >  #\n> >  #     When set to \"1\", do not include \"DWIM\" suggestions in git-checkout\n> >  #     completion (e.g., completing \"foo\" when \"origin/foo\" exists).\n> > +#\n> > +#   GIT_COMPLETION_OPTIONS\n> > +#\n> > +#     When set to \"all\", complete all possible options\n> \n> I was going to suggest some wording like:\n> \n>     When set to \"all\", include options considered unsafe such as --force\n>     in the completion.\n> \n> However per your cover letter it's not just used for that:\n> \n>      10 --force\n>       4 --rerere-autoupdate\n>       1 --unsafe-paths\n>       1 --thin\n>       1 --overwrite-ignore\n>       1 --open-files-in-pager\n>       1 --null\n>       1 --ext-grep\n>       1 --exit-code\n>       1 --auto\n> \n> I wonder if we shouldn't just make this only about --force, I don't see\n> why \"git grep --o<TAB>\" should only show --or but not\n> --open-files-in-pager, and e.g. \"git grep --<TAB>\" is already verbose so\n> we're not saving much by excluding those.\n> \n> Then this could just become:\n> \n>     GIT_COMPLETION_SHOWUNSAFEOPTIONS=1\n> \n> Or other similar boolean variable, for consistency with all the \"*SHOW*\n> variables already in git-completion.bash.\n\nNo. You're asking for a second default. I'm not adding plenty of\nGIT_COMPLETION_* variables for that. You either have all options, or\nyou convince people that --force should be part of the current\ndefault.\n\nOr you could push for a generic mechanism that allows you to customize\nyour own default. Something like the below patch could give you what\nyou want with:\n\n    GIT_COMPLETION_OPTIONS=all\n    GIT_COMPLETION_EXCLUDES=--open-files-in-pager # and some more\n    . /path/to/git-completion.bash\n\nI'm not going to make a real patch for this since people may want to\nignore --foo in one command and complete --foo in others... I'm just\nnot interested in trying to cover all cases.\n\n-- 8< --\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0cfa489a8e..9ca0d80cd7 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -40,6 +40,10 @@\n #   GIT_COMPLETION_OPTIONS\n #\n #     When set to \"all\", complete all possible options\n+#\n+#   GIT_COMPLETION_EXCLUDES\n+#\n+#     Exclude some options from the complete list\n \n case \"$COMP_WORDBREAKS\" in\n *:*) : great ;;\n@@ -298,7 +302,7 @@ __gitcomp_builtin ()\n \t# commands, e.g. \"git remote add\" becomes remote_add.\n \tlocal cmd=\"$1\"\n \tlocal incl=\"$2\"\n-\tlocal excl=\"$3\"\n+\tlocal excl=\"$3 $GIT_COMPLETION_EXCLUDES\"\n \n \tlocal var=__gitcomp_builtin_\"${cmd/-/_}\"\n \tlocal options\n-- 8< --\n"},{"id":"339012","messageId":"CAPig+cT63UnZ1qLKc-Rk4k0ixL93ywd-i6AFH3mFJOWq2QpuBQ@mail.gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-43-pclouds@gmail.com","subject":"Re: [PATCH v3 42/42] git-completion.bash: add GIT_COMPLETION_OPTIONS=all config","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-02-11T01:59:48Z","receivedAt":"2018-02-11T01:59:53Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Feb 9, 2018 at 6:02 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> By default, some option names (mostly --force, scripting related or for\n> internal use) are not completable for various reasons. When\n> GIT_COMPLETION_OPTIONS is set to all, all options (except hidden ones)\n> are completable.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> @@ -36,6 +36,10 @@\n> +#\n> +#   GIT_COMPLETION_OPTIONS\n> +#\n> +#     When set to \"all\", complete all possible options\n> @@ -303,7 +307,7 @@ __gitcomp_builtin ()\n>         if [ -z \"$options\" ]; then\n>                 # leading and trailing spaces are significant to make\n>                 # option removal work correctly.\n> -               options=\" $(__git ${cmd/_/ } --git-completion-helper) $incl \"\n> +               options=\" $(__git ${cmd/_/ } --git-completion-helper=$GIT_COMPLETION_OPTIONS) $incl \"\n\nThis approach is rather different from what I had envisioned. Rather\nthan asking --git-completion-helper to do the filtering, my thought\nwas that it should unconditionally dump _all_ options but annotate\nthem, and then git-completion.bash can filter however it sees fit. For\ninstance, --git-completion-helper might annotate \"dangerous\" options\nwith a \"!\" (\"!--force\" or \"--force!\" or \"--force:!\" or whatever).\n\nThe benefit of this approach is that it more easily supports future\nenhancements. For instance, options which only make sense in certain\ncontexts could be annotated to indicate such. An example are the\n--continue, --abort, --skip options for git-rebase which only make\nsense when a rebase session is active. One could imagine these options\nbeing annotated something like this:\n\n    --abort:rebasing\n    --continue:rebasing\n    --skip:rebasing\n\nwhere git-completion.bash understands the \"rebasing\" annotation as\nmeaning that these options only make sense when \"rebase-apply\" is\npresent. (In fact, the annotation could be more expressive, such as\n\"--abort:exists(rebase-apply)\", but that might be overkill.)\n"},{"id":"339019","messageId":"874lmnk2gb.fsf@evledraar.gmail.com","threadId":"47727","inReplyTo":"20180210092945.GA6370@ash","subject":"Re: [PATCH v3 42/42] git-completion.bash: add GIT_COMPLETION_OPTIONS=all config","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-02-11T14:47:48Z","receivedAt":"2018-02-11T14:47:56Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sat, Feb 10 2018, Duy Nguyen jotted:\n\n> On Fri, Feb 09, 2018 at 03:19:57PM +0100, Ævar Arnfjörð Bjarmason wrote:\n>>\n>> On Fri, Feb 09 2018, Nguyễn Thái Ngọc Duy jotted:\n>>\n>> > By default, some option names (mostly --force, scripting related or for\n>> > internal use) are not completable for various reasons. When\n>> > GIT_COMPLETION_OPTIONS is set to all, all options (except hidden ones)\n>> > are completable.\n>> >\n>> > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> > ---\n>> >  contrib/completion/git-completion.bash |  6 +++++-\n>> >  parse-options.c                        | 11 +++++++----\n>> >  2 files changed, 12 insertions(+), 5 deletions(-)\n>> >\n>> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> > index 0ddf40063b..0cfa489a8e 100644\n>> > --- a/contrib/completion/git-completion.bash\n>> > +++ b/contrib/completion/git-completion.bash\n>> > @@ -36,6 +36,10 @@\n>> >  #\n>> >  #     When set to \"1\", do not include \"DWIM\" suggestions in git-checkout\n>> >  #     completion (e.g., completing \"foo\" when \"origin/foo\" exists).\n>> > +#\n>> > +#   GIT_COMPLETION_OPTIONS\n>> > +#\n>> > +#     When set to \"all\", complete all possible options\n>>\n>> I was going to suggest some wording like:\n>>\n>>     When set to \"all\", include options considered unsafe such as --force\n>>     in the completion.\n>>\n>> However per your cover letter it's not just used for that:\n>>\n>>      10 --force\n>>       4 --rerere-autoupdate\n>>       1 --unsafe-paths\n>>       1 --thin\n>>       1 --overwrite-ignore\n>>       1 --open-files-in-pager\n>>       1 --null\n>>       1 --ext-grep\n>>       1 --exit-code\n>>       1 --auto\n>>\n>> I wonder if we shouldn't just make this only about --force, I don't see\n>> why \"git grep --o<TAB>\" should only show --or but not\n>> --open-files-in-pager, and e.g. \"git grep --<TAB>\" is already verbose so\n>> we're not saving much by excluding those.\n>>\n>> Then this could just become:\n>>\n>>     GIT_COMPLETION_SHOWUNSAFEOPTIONS=1\n>>\n>> Or other similar boolean variable, for consistency with all the \"*SHOW*\n>> variables already in git-completion.bash.\n>\n> No. You're asking for a second default. I'm not adding plenty of\n> GIT_COMPLETION_* variables for that. You either have all options, or\n> you convince people that --force should be part of the current\n> default.\n\nNo sorry, I mean that IMO the current patch you have could be simplified\nwhere instead of saying \"=all\" there's just another variable that only\nhides \"dangerous\" options, i.e. only \"--force\" (unless I've missed\nanother supposedly dangerous one).\n\nBut as previously discussed I think it just makes sense to stop doing\nthis conditionally and include --force too, the only stuff we should\nhide is stuff like rebase --continue when not in an interactive rebase.\n\n> Or you could push for a generic mechanism that allows you to customize\n> your own default. Something like the below patch could give you what\n> you want with:\n>\n>     GIT_COMPLETION_OPTIONS=all\n>     GIT_COMPLETION_EXCLUDES=--open-files-in-pager # and some more\n>     . /path/to/git-completion.bash\n>\n> I'm not going to make a real patch for this since people may want to\n> ignore --foo in one command and complete --foo in others... I'm just\n> not interested in trying to cover all cases.\n>\n> -- 8< --\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 0cfa489a8e..9ca0d80cd7 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -40,6 +40,10 @@\n>  #   GIT_COMPLETION_OPTIONS\n>  #\n>  #     When set to \"all\", complete all possible options\n> +#\n> +#   GIT_COMPLETION_EXCLUDES\n> +#\n> +#     Exclude some options from the complete list\n>\n>  case \"$COMP_WORDBREAKS\" in\n>  *:*) : great ;;\n> @@ -298,7 +302,7 @@ __gitcomp_builtin ()\n>  \t# commands, e.g. \"git remote add\" becomes remote_add.\n>  \tlocal cmd=\"$1\"\n>  \tlocal incl=\"$2\"\n> -\tlocal excl=\"$3\"\n> +\tlocal excl=\"$3 $GIT_COMPLETION_EXCLUDES\"\n>\n>  \tlocal var=__gitcomp_builtin_\"${cmd/-/_}\"\n>  \tlocal options\n> -- 8< --\n"},{"id":"339030","messageId":"CACsJy8BoPxbt=hqAd9fS7MLiF33FVtAk0=Fr_q7UgYy1YvEg0w@mail.gmail.com","threadId":"47727","inReplyTo":"CAPig+cT63UnZ1qLKc-Rk4k0ixL93ywd-i6AFH3mFJOWq2QpuBQ@mail.gmail.com","subject":"Re: [PATCH v3 42/42] git-completion.bash: add GIT_COMPLETION_OPTIONS=all config","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-12T00:34:22Z","receivedAt":"2018-02-12T00:34:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, Feb 11, 2018 at 8:59 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Fri, Feb 9, 2018 at 6:02 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>> By default, some option names (mostly --force, scripting related or for\n>> internal use) are not completable for various reasons. When\n>> GIT_COMPLETION_OPTIONS is set to all, all options (except hidden ones)\n>> are completable.\n>>\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> @@ -36,6 +36,10 @@\n>> +#\n>> +#   GIT_COMPLETION_OPTIONS\n>> +#\n>> +#     When set to \"all\", complete all possible options\n>> @@ -303,7 +307,7 @@ __gitcomp_builtin ()\n>>         if [ -z \"$options\" ]; then\n>>                 # leading and trailing spaces are significant to make\n>>                 # option removal work correctly.\n>> -               options=\" $(__git ${cmd/_/ } --git-completion-helper) $incl \"\n>> +               options=\" $(__git ${cmd/_/ } --git-completion-helper=$GIT_COMPLETION_OPTIONS) $incl \"\n>\n> This approach is rather different from what I had envisioned. Rather\n> than asking --git-completion-helper to do the filtering, my thought\n> was that it should unconditionally dump _all_ options but annotate\n> them, and then git-completion.bash can filter however it sees fit. For\n> instance, --git-completion-helper might annotate \"dangerous\" options\n> with a \"!\" (\"!--force\" or \"--force!\" or \"--force:!\" or whatever).\n>\n> The benefit of this approach is that it more easily supports future\n> enhancements. For instance, options which only make sense in certain\n> contexts could be annotated to indicate such. An example are the\n> --continue, --abort, --skip options for git-rebase which only make\n> sense when a rebase session is active. One could imagine these options\n> being annotated something like this:\n>\n>     --abort:rebasing\n>     --continue:rebasing\n>     --skip:rebasing\n>\n> where git-completion.bash understands the \"rebasing\" annotation as\n> meaning that these options only make sense when \"rebase-apply\" is\n> present. (In fact, the annotation could be more expressive, such as\n> \"--abort:exists(rebase-apply)\", but that might be overkill.)\n\nI agree. I went a bit off track with this ...=all. But yes some form\nof annotation will be needed long term to describe these options in\ndetails. We haven't gotten the annotation in struct option[] to this\nlevel yet, it's a bit hard to see what will be needed here. Let's drop\n42/42 for now. I will study git-completion.bash more to see what it\nneeds and revisit this at some point in future.\n-- \nDuy\n"},{"id":"339274","messageId":"CAM0VKjmFEyr4qHdc1qfW0M_RZ7cM9bCfsn-M4Rapzt6CPhZE1g@mail.gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-7-pclouds@gmail.com","subject":"Re: [PATCH v3 06/42] completion: use __gitcomp_builtin in _git_am","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2018-02-14T12:53:22Z","receivedAt":"2018-02-14T12:53:28Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Feb 9, 2018 at 12:01 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> The new completable options are:\n>\n> --directory\n> --exclude\n> --gpg-sign\n> --include\n> --keep-cr\n> --keep-non-patch\n> --message-id\n> --no-keep-cr\n> --patch-format\n> --quiet\n> --reject\n> --resolvemsg=\n>\n> In-progress options like --continue will be part of --git-completion-helper\n> then filtered out by _git_am() unless the operation is in progress. This\n> helps keep marking of these operations in just one place.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash | 11 ++++-------\n>  parse-options.h                        |  4 ++--\n>  rerere.h                               |  3 ++-\n>  3 files changed, 8 insertions(+), 10 deletions(-)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 1e0bd835fe..eba482eb9c 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1105,12 +1105,13 @@ __git_count_arguments ()\n>  }\n>\n>  __git_whitespacelist=\"nowarn warn error error-all fix\"\n> +__git_am_inprogress_options=\"--skip --continue --resolved --abort\"\n>\n>  _git_am ()\n>  {\n>         __git_find_repo_path\n>         if [ -d \"$__git_repo_path\"/rebase-apply ]; then\n> -               __gitcomp \"--skip --continue --resolved --abort\"\n> +               __gitcomp \"$__git_am_inprogress_options\"\n>                 return\n>         fi\n>         case \"$cur\" in\n> @@ -1119,12 +1120,8 @@ _git_am ()\n>                 return\n>                 ;;\n>         --*)\n> -               __gitcomp \"\n> -                       --3way --committer-date-is-author-date --ignore-date\n> -                       --ignore-whitespace --ignore-space-change\n> -                       --interactive --keep --no-utf8 --signoff --utf8\n> -                       --whitespace= --scissors\n> -                       \"\n> +               __gitcomp_builtin am \"--no-utf8\" \\\n> +                       \"$__git_am_inprogress_options\"\n>                 return\n>         esac\n>  }\n> diff --git a/parse-options.h b/parse-options.h\n> index 3c32401736..009cd863e5 100644\n> --- a/parse-options.h\n> +++ b/parse-options.h\n> @@ -144,8 +144,8 @@ struct option {\n>  #define OPT_STRING_LIST(s, l, v, a, h) \\\n>                                     { OPTION_CALLBACK, (s), (l), (v), (a), \\\n>                                       (h), 0, &parse_opt_string_list }\n> -#define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n> -                                     (h), PARSE_OPT_NOARG, &parse_opt_tertiary }\n> +#define OPT_UYN(s, l, v, h, f)      { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n> +                                     (h), PARSE_OPT_NOARG|(f), &parse_opt_tertiary }\n>  #define OPT_DATE(s, l, v, h) \\\n>         { OPTION_CALLBACK, (s), (l), (v), N_(\"time\"),(h), 0,    \\\n>           parse_opt_approxidate_cb }\n\nShouldn't this hunk go into a commit of its own?  Or at least it would\ndeserve a mention in the commit message.\n\n\n> diff --git a/rerere.h b/rerere.h\n> index c2961feaaa..5e5a312e4c 100644\n> --- a/rerere.h\n> +++ b/rerere.h\n> @@ -37,6 +37,7 @@ extern void rerere_clear(struct string_list *);\n>  extern void rerere_gc(struct string_list *);\n>\n>  #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, \"rerere-autoupdate\", (v), \\\n> -       N_(\"update the index with reused conflict resolution if possible\"))\n> +       N_(\"update the index with reused conflict resolution if possible\"), \\\n> +       PARSE_OPT_NOCOMPLETE)\n>\n>  #endif\n> --\n> 2.16.1.207.gedba492059\n>\n"},{"id":"339280","messageId":"CAM0VKjmJwDUv4gTQ+22SgfX+=PahXRPeP=774hV7mxxm3nXiYg@mail.gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-30-pclouds@gmail.com","subject":"Re: [PATCH v3 29/42] completion: use __gitcomp_builtin in _git_notes","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2018-02-14T14:29:34Z","receivedAt":"2018-02-14T14:29:40Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Feb 9, 2018 at 12:02 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index c7b8b37f19..60127daebf 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n\n> @@ -1851,15 +1851,17 @@ _git_notes ()\n>         add,--reedit-message=*|append,--reedit-message=*)\n>                 __git_complete_refs --cur=\"${cur#*=}\"\n>                 ;;\n> -       add,--*|append,--*)\n> -               __gitcomp '--file= --message= --reedit-message=\n> -                               --reuse-message='\n> +       add,--*)\n> +               __gitcomp_builtin notes_add\n> +               ;;\n> +       append,--*)\n> +               __gitcomp_builtin notes_append\n>                 ;;\n>         copy,--*)\n> -               __gitcomp '--stdin'\n> +               __gitcomp_builtin notes_copy\n>                 ;;\n>         prune,--*)\n> -               __gitcomp '--dry-run --verbose'\n> +               __gitcomp_builtin notes_prune\n>                 ;;\n>         prune,*)\n>                 ;;\n\nThis could be simplified to:\n\n  add,--*|append,--*|copy,--*|prune,--*)\n        __gitcomp_builtin notes_$subcommand\n        ;;\n\nAnd we could even go one step further:\n\n  *,--*)\n        __gitcomp_builtin notes_$subcommand\n        ;;\n\nThis would have the benefit that if any of the remaining subcommands\nlearn --options, then they would be completed right away, without the\nneed to add that subcommand to the case arms.  Case in point is 'git\nnotes remove', which already accepts two options, but they are not\ncompleted because of the missing 'remove,--*)' case arm.  The same would\nalso apply to 'git notes merge's options, except that the completion\nscript completely misses the 'merge' subcommand in the first place\n(blame on me, 2a5da75579 (bash: support more 'git notes' subcommands and\ntheir options, 2010-10-10)).\n\nThis also applies to the completion functions of other commands with\nsubcommands ('remote', 'worktree').\n\nThe downside is that we would run 'git cmd subcmd\n--git-completion-helper' even if a subcommand doesn't use parse options.\nI think that's acceptable.\n"},{"id":"339284","messageId":"CAM0VKjkOpQ-bxQJ0FQtqOycKQEfEHywVEuwAQyKRZs9VsDtb1w@mail.gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-30-pclouds@gmail.com","subject":"Re: [PATCH v3 29/42] completion: use __gitcomp_builtin in _git_notes","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2018-02-14T15:15:45Z","receivedAt":"2018-02-14T15:15:52Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Feb 9, 2018 at 12:02 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index c7b8b37f19..60127daebf 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1835,7 +1835,7 @@ _git_notes ()\n>\n>         case \"$subcommand,$cur\" in\n>         ,--*)\n> -               __gitcomp '--ref'\n> +               __gitcomp_builtin notes\n>                 ;;\n>         ,*)\n>                 case \"$prev\" in\n\nHmm, after this patch is applied, this part of _git_notes() looks like\nthis:\n\n        case \"$subcommand,$cur\" in\n        <skip>\n        ,*)\n                case \"$prev\" in\n                --ref)\n                        __git_complete_refs\n                        ;;\n                *)\n                        __gitcomp \"$subcommands --ref\"\n                        ;;\n                esac\n                ;;\n\nNote that '--ref' option passed to __gitcomp() along with the\nsubcommands.\n\nIt would be great if that option could come from parse options as well,\nbut we can't rely on $__gitcomp_builtin_notes being already initialized\nat this point and the current __gitcomp_builtin function tightly couples\ninitializing that variable and completing options.\n\nIt would be even greater, if all the subcommands could come from parse\noptions as well, but not sure how that would fit into parse options,\nbecause subcommands are, well, not --options.\n\nThere are only a few commands with subcommands whose main command\naccepts an --option, too; I could only find 'notes', 'remote', 'stash'\nand 'submodule'.  The latter two are scripts, and for 'remote' we don't\noffer its '--verbose' option along with its subcommands, but perhaps we\nshould.  Anyway, considering that there are only two such cases at the\nmoment, I think we could live with that two hard-coded options.\n"},{"id":"339285","messageId":"CAM0VKjk17VgGAHr8jJXft4twij61KPLUDYSeHm6TXttksynd8Q@mail.gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-5-pclouds@gmail.com","subject":"Re: [PATCH v3 04/42] git-completion.bash: introduce __gitcomp_builtin","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2018-02-14T15:35:28Z","receivedAt":"2018-02-14T15:35:34Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Thanks for working on this.  I anticipated that the completion script\nlack some options, but wow, I didn't expect that there are so many\nmissing.\n\nOn Fri, Feb 9, 2018 at 12:01 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> This is a __gitcomp wrapper that will execute\n>\n>     git ... --git-completion-helper\n>\n> to get the list of completable options. The call will be made only\n> once and cached to avoid performance issues, especially on Windows.\n\nNit: the call will be made every time; 'git ... --git-completion-helper'\nwill be executed only once.\n\n> __gitcomp_builtin() allows callers to change its output a bit by adding\n> some more options, or removing some.\n>\n> - Current --git-completion-helper for example does not output --no-foo\n>   form, this has to be added manually by __gitcomp_builtin() callers\n>   when necessary\n>\n> - Some options from --git-completion-helper should only be available in\n>   certain conditions (e.g. --continue and friends). __gitcomp_builtin()\n>   callers can remove them if the conditions are not met.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash | 33 ++++++++++++++++++++++++++\n>  1 file changed, 33 insertions(+)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 3683c772c5..85e7f26328 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -280,6 +280,39 @@ __gitcomp ()\n>         esac\n>  }\n>\n> +# This function is equivalent to\n> +#\n> +#    __gitcomp \"$(git xxx --git-completion-helper) ...\"\n> +#\n> +# except that the output is cached. Accept 1-3 arguments:\n> +# 1: the git command to execute, this is also the cache key\n> +# 2: extra options to be added on top (e.g. negative forms)\n> +# 3: options to be excluded\n> +__gitcomp_builtin ()\n\nPlease excuse the bikeshed at v3, but I don't like the name of this\nfunction.  It indicates that it completes builtins, but it completes\noptions of builtins, and even then only the options of those using parse\noptions.  Furthermore, the '__gitcomp' prefix is usually used for\nfunctions that merely put words into COMPREPLY, but this function does a\nwhole lot more (getting the options from builtins, include and exclude\noptions, caching).\n\nAlas I don't have any great name; __git_complete_options is better,\nbecause it uses the right function name prefix, but only slightly\nbetter, because it can't generally be used to complete options, as it\nwon't work with scripts or with builtins not using parse options (though\nwith time more scripts will be turned into builtins and more builtins\nwill use parse options).  I'm not sure it's that match better to make it\nworth changing fourty-odd patches.\n\n> +{\n> +       # spaces must be replaced with underscore for multi-word\n> +       # commands, e.g. \"git remote add\" becomes remote_add.\n> +       local cmd=\"$1\"\n\nThe alternative would be 'command subcommand', i.e. keeping that space,\nand in that case we could spare the ${cmd/_/ } in this function, and\ncould even say '__gitcomp \"$(git $1 --git-completion-helper)\" in the\nequivalent example above; OTOH we would need quoting on all callsites\nwith subcommands.  Again, I'm not sure it's worth it.\n\n> +       local incl=\"$2\"\n> +       local excl=\"$3\"\n> +\n> +       local var=__gitcomp_builtin_\"${cmd/-/_}\"\n> +       local options\n> +       eval \"options=\\$$var\"\n> +\n> +       if [ -z \"$options\" ]; then\n> +               # leading and trailing spaces are significant to make\n> +               # option removal work correctly.\n> +               options=\" $(__git ${cmd/_/ } --git-completion-helper) $incl \"\n> +               for i in $excl; do\n> +                       options=\"${options/ $i / }\"\n> +               done\n> +               eval \"$var=\\\"$options\\\"\"\n> +       fi\n> +\n> +       __gitcomp \"$options\"\n> +}\n> +\n>  # Variation of __gitcomp_nl () that appends to the existing list of\n>  # completion candidates, COMPREPLY.\n>  __gitcomp_nl_append ()\n> --\n> 2.16.1.207.gedba492059\n>\n"},{"id":"339913","messageId":"CACsJy8CWdJJigQSEjGuhoH1URGY8=YSAHiqhaGBZK7Zr8GZUGg@mail.gmail.com","threadId":"47727","inReplyTo":"CAM0VKjmFEyr4qHdc1qfW0M_RZ7cM9bCfsn-M4Rapzt6CPhZE1g@mail.gmail.com","subject":"Re: [PATCH v3 06/42] completion: use __gitcomp_builtin in _git_am","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-22T09:13:51Z","receivedAt":"2018-02-22T09:14:28Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Feb 14, 2018 at 7:53 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:\n> On Fri, Feb 9, 2018 at 12:01 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>> The new completable options are:\n>>\n>> --directory\n>> --exclude\n>> --gpg-sign\n>> --include\n>> --keep-cr\n>> --keep-non-patch\n>> --message-id\n>> --no-keep-cr\n>> --patch-format\n>> --quiet\n>> --reject\n>> --resolvemsg=\n>>\n>> In-progress options like --continue will be part of --git-completion-helper\n>> then filtered out by _git_am() unless the operation is in progress. This\n>> helps keep marking of these operations in just one place.\n>>\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>>  contrib/completion/git-completion.bash | 11 ++++-------\n>>  parse-options.h                        |  4 ++--\n>>  rerere.h                               |  3 ++-\n>>  3 files changed, 8 insertions(+), 10 deletions(-)\n>>\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index 1e0bd835fe..eba482eb9c 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -1105,12 +1105,13 @@ __git_count_arguments ()\n>>  }\n>>\n>>  __git_whitespacelist=\"nowarn warn error error-all fix\"\n>> +__git_am_inprogress_options=\"--skip --continue --resolved --abort\"\n>>\n>>  _git_am ()\n>>  {\n>>         __git_find_repo_path\n>>         if [ -d \"$__git_repo_path\"/rebase-apply ]; then\n>> -               __gitcomp \"--skip --continue --resolved --abort\"\n>> +               __gitcomp \"$__git_am_inprogress_options\"\n>>                 return\n>>         fi\n>>         case \"$cur\" in\n>> @@ -1119,12 +1120,8 @@ _git_am ()\n>>                 return\n>>                 ;;\n>>         --*)\n>> -               __gitcomp \"\n>> -                       --3way --committer-date-is-author-date --ignore-date\n>> -                       --ignore-whitespace --ignore-space-change\n>> -                       --interactive --keep --no-utf8 --signoff --utf8\n>> -                       --whitespace= --scissors\n>> -                       \"\n>> +               __gitcomp_builtin am \"--no-utf8\" \\\n>> +                       \"$__git_am_inprogress_options\"\n>>                 return\n>>         esac\n>>  }\n>> diff --git a/parse-options.h b/parse-options.h\n>> index 3c32401736..009cd863e5 100644\n>> --- a/parse-options.h\n>> +++ b/parse-options.h\n>> @@ -144,8 +144,8 @@ struct option {\n>>  #define OPT_STRING_LIST(s, l, v, a, h) \\\n>>                                     { OPTION_CALLBACK, (s), (l), (v), (a), \\\n>>                                       (h), 0, &parse_opt_string_list }\n>> -#define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n>> -                                     (h), PARSE_OPT_NOARG, &parse_opt_tertiary }\n>> +#define OPT_UYN(s, l, v, h, f)      { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n>> +                                     (h), PARSE_OPT_NOARG|(f), &parse_opt_tertiary }\n>>  #define OPT_DATE(s, l, v, h) \\\n>>         { OPTION_CALLBACK, (s), (l), (v), N_(\"time\"),(h), 0,    \\\n>>           parse_opt_approxidate_cb }\n>\n> Shouldn't this hunk go into a commit of its own?  Or at least it would\n> deserve a mention in the commit message.\n\nIt's not a standalone change. It is used by the OPT_RERERE_AUTOUPDATE\nbelow, which in turn is used by git-add. Together, --rerere-autoupdate\nis removed from the completion list of git-add (and also a few more\ncommands).\n\nNow that you mention it, the only command that completes\n--rerere-autoupdate is git-merge. Since this is \"auto\" I don't think\npeople want to type manually. Maybe I should separate these changes\n_and_ remove --rerere-autoupdate from _git_merge() too? At least that\nit will be consistent that way.\n\n>> diff --git a/rerere.h b/rerere.h\n>> index c2961feaaa..5e5a312e4c 100644\n>> --- a/rerere.h\n>> +++ b/rerere.h\n>> @@ -37,6 +37,7 @@ extern void rerere_clear(struct string_list *);\n>>  extern void rerere_gc(struct string_list *);\n>>\n>>  #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, \"rerere-autoupdate\", (v), \\\n>> -       N_(\"update the index with reused conflict resolution if possible\"))\n>> +       N_(\"update the index with reused conflict resolution if possible\"), \\\n>> +       PARSE_OPT_NOCOMPLETE)\n>>\n>>  #endif\n>> --\n>> 2.16.1.207.gedba492059\n>>\n\n\n\n-- \nDuy\n"},{"id":"339932","messageId":"xmqqsh9sx4xk.fsf@gitster-ct.c.googlers.com","threadId":"47727","inReplyTo":"CACsJy8CWdJJigQSEjGuhoH1URGY8=YSAHiqhaGBZK7Zr8GZUGg@mail.gmail.com","subject":"Re: [PATCH v3 06/42] completion: use __gitcomp_builtin in _git_am","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-02-22T18:19:51Z","receivedAt":"2018-02-22T18:20:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> Now that you mention it, the only command that completes\n> --rerere-autoupdate is git-merge. Since this is \"auto\" I don't think\n> people want to type manually.\n\nSorry, but I do not quite get the connection between \"since this is\n'auto'\" and the rest of the sentence.  Is it just it is so lengthy\nthat people do not want to type and are likely to use completion?\n\n> Maybe I should separate these changes\n> _and_ remove --rerere-autoupdate from _git_merge() too? At least that\n> it will be consistent that way.\n\nHmmmm.  Why not complete this option?  Is it because the current\ncompletion script does not and we are trying to preserve the\nbehaviour?  I do not have a strong opinion either way, but just\ntrying to understand the reasoning behind the choice.\n\n>>> diff --git a/rerere.h b/rerere.h\n>>> index c2961feaaa..5e5a312e4c 100644\n>>> --- a/rerere.h\n>>> +++ b/rerere.h\n>>> @@ -37,6 +37,7 @@ extern void rerere_clear(struct string_list *);\n>>>  extern void rerere_gc(struct string_list *);\n>>>\n>>>  #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, \"rerere-autoupdate\", (v), \\\n>>> -       N_(\"update the index with reused conflict resolution if possible\"))\n>>> +       N_(\"update the index with reused conflict resolution if possible\"), \\\n>>> +       PARSE_OPT_NOCOMPLETE)\n>>>\n>>>  #endif\n>>> --\n>>> 2.16.1.207.gedba492059\n>>>\n"},{"id":"340007","messageId":"CACsJy8DWwOezWpTVmpndhvhujzGV79uT2RqpZJxcp7oLr7G+-g@mail.gmail.com","threadId":"47727","inReplyTo":"xmqqsh9sx4xk.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 06/42] completion: use __gitcomp_builtin in _git_am","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-23T10:17:33Z","receivedAt":"2018-02-23T10:18:11Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 23, 2018 at 1:19 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Duy Nguyen <pclouds@gmail.com> writes:\n>\n>> Now that you mention it, the only command that completes\n>> --rerere-autoupdate is git-merge. Since this is \"auto\" I don't think\n>> people want to type manually.\n>\n> Sorry, but I do not quite get the connection between \"since this is\n> 'auto'\" and the rest of the sentence.  Is it just it is so lengthy\n> that people do not want to type and are likely to use completion?\n\nWell, if it is to be done automatically, I should not need to tell it\nmanually (by typing the option on command line). Granted it's a weak\nargument.\n\n>> Maybe I should separate these changes\n>> _and_ remove --rerere-autoupdate from _git_merge() too? At least that\n>> it will be consistent that way.\n>\n> Hmmmm.  Why not complete this option?  Is it because the current\n> completion script does not and we are trying to preserve the\n> behaviour?  I do not have a strong opinion either way, but just\n> trying to understand the reasoning behind the choice.\n\nThere's not a strong argument for not completing this option really.\n\nIt may belong to the unpopular category and adding it may make people\n<TAB> more for other options. But I think it's way too early to decide\nthat. And even if that's true, I think we should let the user choose\nto not complete certain options they don't like.\n\nIt's good that this is spotted. I think I'll just keep all\n--rerere-autoupdate completable. Well, v4's coming (in a few days)...\n-- \nDuy\n"},{"id":"340011","messageId":"CACsJy8Avto9W_xUJLv+_uQMXLOsXDBz1Bo8kqZNhzs1dKKhb0A@mail.gmail.com","threadId":"47727","inReplyTo":"CAM0VKjk17VgGAHr8jJXft4twij61KPLUDYSeHm6TXttksynd8Q@mail.gmail.com","subject":"Re: [PATCH v3 04/42] git-completion.bash: introduce __gitcomp_builtin","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-23T10:30:09Z","receivedAt":"2018-02-23T10:30:47Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Feb 14, 2018 at 10:35 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:\n>> +__gitcomp_builtin ()\n>\n> Please excuse the bikeshed at v3, but I don't like the name of this\n> function.  It indicates that it completes builtins, but it completes\n> options of builtins, and even then only the options of those using parse\n> options.  Furthermore, the '__gitcomp' prefix is usually used for\n> functions that merely put words into COMPREPLY, but this function does a\n> whole lot more (getting the options from builtins, include and exclude\n> options, caching).\n>\n> Alas I don't have any great name; __git_complete_options is better,\n> because it uses the right function name prefix, but only slightly\n> better, because it can't generally be used to complete options, as it\n> won't work with scripts or with builtins not using parse options (though\n> with time more scripts will be turned into builtins and more builtins\n> will use parse options).  I'm not sure it's that match better to make it\n> worth changing fourty-odd patches.\n\nSince it's still on 'pu', renaming is still an option. I don't mind\nrenaming (and I'll need to check every patch anyway when I make\n--rerere-autoupdate completable). Say \"do\" and I will.\n-- \nDuy\n"},{"id":"340012","messageId":"CACsJy8CQJViiDVuEXH-zkY_yX5AUahJCCshX=jedHhVvfpMUiA@mail.gmail.com","threadId":"47727","inReplyTo":"CAM0VKjmJwDUv4gTQ+22SgfX+=PahXRPeP=774hV7mxxm3nXiYg@mail.gmail.com","subject":"Re: [PATCH v3 29/42] completion: use __gitcomp_builtin in _git_notes","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-23T10:33:19Z","receivedAt":"2018-02-23T10:33:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Feb 14, 2018 at 9:29 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:\n> On Fri, Feb 9, 2018 at 12:02 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index c7b8b37f19..60127daebf 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>\n>> @@ -1851,15 +1851,17 @@ _git_notes ()\n>>         add,--reedit-message=*|append,--reedit-message=*)\n>>                 __git_complete_refs --cur=\"${cur#*=}\"\n>>                 ;;\n>> -       add,--*|append,--*)\n>> -               __gitcomp '--file= --message= --reedit-message=\n>> -                               --reuse-message='\n>> +       add,--*)\n>> +               __gitcomp_builtin notes_add\n>> +               ;;\n>> +       append,--*)\n>> +               __gitcomp_builtin notes_append\n>>                 ;;\n>>         copy,--*)\n>> -               __gitcomp '--stdin'\n>> +               __gitcomp_builtin notes_copy\n>>                 ;;\n>>         prune,--*)\n>> -               __gitcomp '--dry-run --verbose'\n>> +               __gitcomp_builtin notes_prune\n>>                 ;;\n>>         prune,*)\n>>                 ;;\n>\n> This could be simplified to:\n>\n>   add,--*|append,--*|copy,--*|prune,--*)\n>         __gitcomp_builtin notes_$subcommand\n>         ;;\n>\n> And we could even go one step further:\n>\n>   *,--*)\n>         __gitcomp_builtin notes_$subcommand\n>         ;;\n>\n> This would have the benefit that if any of the remaining subcommands\n> learn --options, then they would be completed right away, without the\n> need to add that subcommand to the case arms.\n\nYou read my mind ;-) We won't do this in this series though (but I\nwill simplify the code as suggested). parse-options.c does not have\nany concept about these subcommands. So a bit more work and can (and\nwill) be done separately.\n-- \nDuy\n"},{"id":"340013","messageId":"CACsJy8CEFC56VzQcCzzZKkhvttQc0kUZXDZ55oZXgu=qOuQoUA@mail.gmail.com","threadId":"47727","inReplyTo":"CAM0VKjkOpQ-bxQJ0FQtqOycKQEfEHywVEuwAQyKRZs9VsDtb1w@mail.gmail.com","subject":"Re: [PATCH v3 29/42] completion: use __gitcomp_builtin in _git_notes","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-23T10:40:57Z","receivedAt":"2018-02-23T10:41:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Feb 14, 2018 at 10:15 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:\n> On Fri, Feb 9, 2018 at 12:02 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index c7b8b37f19..60127daebf 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -1835,7 +1835,7 @@ _git_notes ()\n>>\n>>         case \"$subcommand,$cur\" in\n>>         ,--*)\n>> -               __gitcomp '--ref'\n>> +               __gitcomp_builtin notes\n>>                 ;;\n>>         ,*)\n>>                 case \"$prev\" in\n>\n> Hmm, after this patch is applied, this part of _git_notes() looks like\n> this:\n>\n>         case \"$subcommand,$cur\" in\n>         <skip>\n>         ,*)\n>                 case \"$prev\" in\n>                 --ref)\n>                         __git_complete_refs\n>                         ;;\n>                 *)\n>                         __gitcomp \"$subcommands --ref\"\n>                         ;;\n>                 esac\n>                 ;;\n>\n> Note that '--ref' option passed to __gitcomp() along with the\n> subcommands.\n>\n> It would be great if that option could come from parse options as well,\n\nYeah. This is where Eric's option annotation thingy comes in very\nhandy. If we can tell git-completion.bash that \"--ref takes a ref\",\nthen we can do __git_complete_refs automatically.\n\nI'm not so sure how to fit all things together yet. Just like you said\nbelow __gitcomp_builtin is very much completing options, not values.\nWorst case scenario, --git-completion-helper could generate the whole\n\"case\" block to be eval'd here, but that also means non-bash\ncompletion is left out.\n\nSo I'm not going to do anything about this yet. Not until I study some\nmore (and your notes here are very helpful)\n\n> but we can't rely on $__gitcomp_builtin_notes being already initialized\n> at this point and the current __gitcomp_builtin function tightly couples\n> initializing that variable and completing options.\n-- \nDuy\n"},{"id":"340014","messageId":"CACsJy8BG41EkqRXft40sjfUxonPGHhW3ikbzs_y7Xwh=2z6erA@mail.gmail.com","threadId":"47727","inReplyTo":"CACsJy8CQJViiDVuEXH-zkY_yX5AUahJCCshX=jedHhVvfpMUiA@mail.gmail.com","subject":"Re: [PATCH v3 29/42] completion: use __gitcomp_builtin in _git_notes","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-23T10:59:40Z","receivedAt":"2018-02-23T11:00:18Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 23, 2018 at 5:33 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Wed, Feb 14, 2018 at 9:29 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:\n>> And we could even go one step further:\n>>\n>>   *,--*)\n>>         __gitcomp_builtin notes_$subcommand\n>>         ;;\n>>\n>> This would have the benefit that if any of the remaining subcommands\n>> learn --options, then they would be completed right away, without the\n>> need to add that subcommand to the case arms.\n>\n> You read my mind ;-) We won't do this in this series though (but I\n> will simplify the code as suggested). parse-options.c does not have\n> any concept about these subcommands. So a bit more work and can (and\n> will) be done separately.\n\nActually I misread you. This is not about completing subcommands but\nsubcommand's options, so it should work nicely. As long as we make\nsure we handle error cases correctly (e.g. the user try to complete\noptions of a non-existing subcommand)\n-- \nDuy\n"},{"id":"340051","messageId":"xmqq1shbvas1.fsf@gitster-ct.c.googlers.com","threadId":"47727","inReplyTo":"CACsJy8DWwOezWpTVmpndhvhujzGV79uT2RqpZJxcp7oLr7G+-g@mail.gmail.com","subject":"Re: [PATCH v3 06/42] completion: use __gitcomp_builtin in _git_am","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-02-23T18:08:46Z","receivedAt":"2018-02-23T18:34:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Fri, Feb 23, 2018 at 1:19 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Duy Nguyen <pclouds@gmail.com> writes:\n>>\n>>> Now that you mention it, the only command that completes\n>>> --rerere-autoupdate is git-merge. Since this is \"auto\" I don't think\n>>> people want to type manually.\n>>\n>> Sorry, but I do not quite get the connection between \"since this is\n>> 'auto'\" and the rest of the sentence.  Is it just it is so lengthy\n>> that people do not want to type and are likely to use completion?\n>\n> Well, if it is to be done automatically, I should not need to tell it\n> manually (by typing the option on command line). Granted it's a weak\n> argument.\n\nPerhaps I am not reading what the option does correctly, but my\nunderstanding is that merge operations:\n\n - always allow rerere to intervene and auto-resolve in the working\n   tree, as long as rerere is enabled;\n\n - by default they however do not add the rerere-resolved result to\n   the index, so that the combined diff output from \"git diff\" can\n   be used as a way to sanity check the result; but\n\n - if the user says --rerere-autoupdate, they add the\n   rerere-resolved result to the index, letting the user blindly\n   trust it, so that such a trusting user can even commit the result\n   without looking at it by merely making sure there is no path\n   remaining in the \"git ls-files -u\" output.  \n\nThe \"autoupdate\" could be somewhat dangerous depending on your\nworkflow, and that is why the user can selectively enable it via the\ncommand line option (when known to be safe) even if the user does\nnot set rerere.autoupdate to true.\n\nSo I am not sure I understand \"an option to allow something to be\ndone automatically should not be given manually\" as a valid argument\nat all, whether it is weak or strong.\n\nOr am I grossly confused?\n"},{"id":"340164","messageId":"CACsJy8CNUG4sWgMiiyD5CPVhoQ4uYvLDBb+RDiyYUNZ0s9N6kw@mail.gmail.com","threadId":"47727","inReplyTo":"xmqq1shbvas1.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 06/42] completion: use __gitcomp_builtin in _git_am","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-02-24T13:58:56Z","receivedAt":"2018-02-24T13:59:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Feb 24, 2018 at 1:08 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Duy Nguyen <pclouds@gmail.com> writes:\n>\n>> On Fri, Feb 23, 2018 at 1:19 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> Duy Nguyen <pclouds@gmail.com> writes:\n>>>\n>>>> Now that you mention it, the only command that completes\n>>>> --rerere-autoupdate is git-merge. Since this is \"auto\" I don't think\n>>>> people want to type manually.\n>>>\n>>> Sorry, but I do not quite get the connection between \"since this is\n>>> 'auto'\" and the rest of the sentence.  Is it just it is so lengthy\n>>> that people do not want to type and are likely to use completion?\n>>\n>> Well, if it is to be done automatically, I should not need to tell it\n>> manually (by typing the option on command line). Granted it's a weak\n>> argument.\n>\n> Perhaps I am not reading what the option does correctly, but my\n> understanding is that merge operations:\n>\n>  - always allow rerere to intervene and auto-resolve in the working\n>    tree, as long as rerere is enabled;\n>\n>  - by default they however do not add the rerere-resolved result to\n>    the index, so that the combined diff output from \"git diff\" can\n>    be used as a way to sanity check the result; but\n>\n>  - if the user says --rerere-autoupdate, they add the\n>    rerere-resolved result to the index, letting the user blindly\n>    trust it, so that such a trusting user can even commit the result\n>    without looking at it by merely making sure there is no path\n>    remaining in the \"git ls-files -u\" output.\n>\n> The \"autoupdate\" could be somewhat dangerous depending on your\n> workflow, and that is why the user can selectively enable it via the\n> command line option (when known to be safe) even if the user does\n> not set rerere.autoupdate to true.\n>\n> So I am not sure I understand \"an option to allow something to be\n> done automatically should not be given manually\" as a valid argument\n> at all, whether it is weak or strong.\n>\n> Or am I grossly confused?\n\nNope. It's just me not understanding rerere functionality.\n-- \nDuy\n"},{"id":"364441","messageId":"87va4cujtx.fsf@evledraar.gmail.com","threadId":"47727","inReplyTo":"20180209110221.27224-2-pclouds@gmail.com","subject":"Re: [PATCH v3 01/42] parse-options: support --git-completion-helper","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-12-02T13:41:46Z","receivedAt":"2018-12-02T13:41:52Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Feb 09 2018, Nguyễn Thái Ngọc Duy wrote:\n\n> +static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n> +\t\t\tconst struct option *opts)\n> +{\n\nSays it returns 'static int'...\n\n> [...]\n> +\texit(0);\n\nThen just exits...\n\n> +\t\t/* lone --git-completion-helper is asked by git-completion.bash */\n> +\t\tif (ctx->total == 1 && !strcmp(arg + 1, \"-git-completion-helper\"))\n> +\t\t\treturn show_gitcomp(ctx, options);\n\nThis return value is never used.\n\nWhine from SunCC (not fatal, also this was in v2.17.0 so no need to fix\nbefore 2.20, just saw this now):\n\n    \"parse-options.c\", line 520: warning: Function has no return\n    statement : show_gitcomp\n"},{"id":"364842","messageId":"20181209102724.8707-1-pclouds@gmail.com","threadId":"47727","inReplyTo":"87va4cujtx.fsf@evledraar.gmail.com","subject":"[PATCH] parse-options: fix SunCC compiler warning","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-12-09T10:27:24Z","receivedAt":"2018-12-09T10:27:34Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The compiler reports this because show_gitcomp() never actually\nreturns a value:\n\n    \"parse-options.c\", line 520: warning: Function has no return\n    statement : show_gitcomp\n\nThe function calls exit() and will never return. Update and mark it\nNORETURN.\n\nReported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n parse-options.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex 3b874a83a0..6577e52f63 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -474,8 +474,8 @@ static void show_negated_gitcomp(const struct option *opts, int nr_noopts)\n \t}\n }\n \n-static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n-\t\t\tconst struct option *opts)\n+static void NORETURN show_gitcomp(struct parse_opt_ctx_t *ctx,\n+\t\t\t\t  const struct option *opts)\n {\n \tconst struct option *original_opts = opts;\n \tint nr_noopts = 0;\n@@ -550,7 +550,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,\n \n \t\t/* lone --git-completion-helper is asked by git-completion.bash */\n \t\tif (ctx->total == 1 && !strcmp(arg + 1, \"-git-completion-helper\"))\n-\t\t\treturn show_gitcomp(ctx, options);\n+\t\t\tshow_gitcomp(ctx, options);\n \n \t\tif (arg[1] != '-') {\n \t\t\tctx->opt = arg + 1;\n-- \n2.20.0.rc2.486.g9832c05c3d\n\n"},{"id":"364902","messageId":"xmqqy38xkhvd.fsf@gitster-ct.c.googlers.com","threadId":"47727","inReplyTo":"20181209102724.8707-1-pclouds@gmail.com","subject":"Re: [PATCH] parse-options: fix SunCC compiler warning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-10T06:36:54Z","receivedAt":"2018-12-10T06:36:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> The compiler reports this because show_gitcomp() never actually\n> returns a value:\n>\n>     \"parse-options.c\", line 520: warning: Function has no return\n>     statement : show_gitcomp\n>\n> The function calls exit() and will never return. Update and mark it\n> NORETURN.\n\nYuck.  This should do for now, but I am not impressed by the choice\nto hook show_gitcomp() call into parse_options_step(), which forces\nsuch an abnormal exit deeper in the callchain [*1*].  For readers\n(not compilers), it would help to have a comment at the caller that\nsays that show_gitcomp() never returns and exits.\n\n\tside note #1.  Perhaps parse_options_start() would have been\n\ta better place, instead of parse_options_step() that is\n\trepeatedly called in a loop and itself has a loop.  ANd\n\tworse yet, the check is done inside the loop even though the\n\tcall is to be made only when the --git-completion-helper\n\toption is given as the sole request.\n\nThanks.\n\n> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  parse-options.c | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n>\n> diff --git a/parse-options.c b/parse-options.c\n> index 3b874a83a0..6577e52f63 100644\n> --- a/parse-options.c\n> +++ b/parse-options.c\n> @@ -474,8 +474,8 @@ static void show_negated_gitcomp(const struct option *opts, int nr_noopts)\n>  \t}\n>  }\n>  \n> -static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n> -\t\t\tconst struct option *opts)\n> +static void NORETURN show_gitcomp(struct parse_opt_ctx_t *ctx,\n> +\t\t\t\t  const struct option *opts)\n>  {\n>  \tconst struct option *original_opts = opts;\n>  \tint nr_noopts = 0;\n> @@ -550,7 +550,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,\n>  \n>  \t\t/* lone --git-completion-helper is asked by git-completion.bash */\n>  \t\tif (ctx->total == 1 && !strcmp(arg + 1, \"-git-completion-helper\"))\n> -\t\t\treturn show_gitcomp(ctx, options);\n> +\t\t\tshow_gitcomp(ctx, options);\n>  \n>  \t\tif (arg[1] != '-') {\n>  \t\t\tctx->opt = arg + 1;\n"},{"id":"364927","messageId":"20181210152642.GA16203@duynguyen.home","threadId":"47727","inReplyTo":"xmqqy38xkhvd.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] parse-options: fix SunCC compiler warning","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-12-10T15:26:42Z","receivedAt":"2018-12-10T15:26:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Dec 10, 2018 at 03:36:54PM +0900, Junio C Hamano wrote:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n> \n> > The compiler reports this because show_gitcomp() never actually\n> > returns a value:\n> >\n> >     \"parse-options.c\", line 520: warning: Function has no return\n> >     statement : show_gitcomp\n> >\n> > The function calls exit() and will never return. Update and mark it\n> > NORETURN.\n> \n> Yuck.  This should do for now, but I am not impressed by the choice\n> to hook show_gitcomp() call into parse_options_step(), which forces\n> such an abnormal exit deeper in the callchain [*1*].  For readers\n> (not compilers), it would help to have a comment at the caller that\n> says that show_gitcomp() never returns and exits.\n> \n> \tside note #1.  Perhaps parse_options_start() would have been\n> \ta better place, instead of parse_options_step() that is\n> \trepeatedly called in a loop and itself has a loop.  ANd\n> \tworse yet, the check is done inside the loop even though the\n> \tcall is to be made only when the --git-completion-helper\n> \toption is given as the sole request.\n\nThe reason it's in parse_options_step() is because -h is also handled\nin there. Although -h does not bury exit() deep in the call chain. So\nhow about this as a replacement?\n\n-- 8< --\ndiff --git a/parse-options.c b/parse-options.c\nindex 3b874a83a0..6932eaff61 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -516,7 +516,7 @@ static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n \tshow_negated_gitcomp(original_opts, -1);\n \tshow_negated_gitcomp(original_opts, nr_noopts);\n \tfputc('\\n', stdout);\n-\texit(0);\n+\treturn PARSE_OPT_COMPLETE;\n }\n \n static int usage_with_options_internal(struct parse_opt_ctx_t *,\n@@ -638,6 +638,8 @@ int parse_options(int argc, const char **argv, const char *prefix,\n \tcase PARSE_OPT_HELP:\n \tcase PARSE_OPT_ERROR:\n \t\texit(129);\n+\tcase PARSE_OPT_COMPLETE:\n+\t\texit(0);\n \tcase PARSE_OPT_NON_OPTION:\n \tcase PARSE_OPT_DONE:\n \t\tbreak;\ndiff --git a/parse-options.h b/parse-options.h\nindex 6c4fe2016d..a650a7d220 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -208,6 +208,7 @@ extern int opterror(const struct option *opt, const char *reason, int flags);\n /*----- incremental advanced APIs -----*/\n \n enum {\n+\tPARSE_OPT_COMPLETE = -2,\n \tPARSE_OPT_HELP = -1,\n \tPARSE_OPT_DONE,\n \tPARSE_OPT_NON_OPTION,\n-- 8< --\n"},{"id":"365011","messageId":"xmqqk1kgn73c.fsf@gitster-ct.c.googlers.com","threadId":"47727","inReplyTo":"20181210152642.GA16203@duynguyen.home","subject":"Re: [PATCH] parse-options: fix SunCC compiler warning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-11T02:13:43Z","receivedAt":"2018-12-11T02:13:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> The reason it's in parse_options_step() is because -h is also handled\n> in there. Although -h does not bury exit() deep in the call chain. So\n> how about this as a replacement?\n\nSo just like -h returns PARSE_OPT_HELP and causes the calling\nparse_options() to exit(129), the new _COMPLETE can be used to\ntrigger an early & successful return?\n\nWe'd also have to cover builtin/{blame,shortlog,update-index}.c\nwhere they switch() on the return value from parse_options_step(),\nbut other than that, it probably is a better approach.  The users of\nparse_options_step() that avoid parse_options() want to handle the\nvarious \"we stopped by hitting a non-option\" cases in their own\nways, so treating this special action the same way as -h is treated\nwould be sensible.  We _might_ want to standardize some of the case\narms in these custom switch statements that appear in these three\nbuilt-in command implementations, but that can be done more easily\nif this step is done like you showed below, I think.\n\n\n\n\n\n> -- 8< --\n> diff --git a/parse-options.c b/parse-options.c\n> index 3b874a83a0..6932eaff61 100644\n> --- a/parse-options.c\n> +++ b/parse-options.c\n> @@ -516,7 +516,7 @@ static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n>  \tshow_negated_gitcomp(original_opts, -1);\n>  \tshow_negated_gitcomp(original_opts, nr_noopts);\n>  \tfputc('\\n', stdout);\n> -\texit(0);\n> +\treturn PARSE_OPT_COMPLETE;\n>  }\n>  \n>  static int usage_with_options_internal(struct parse_opt_ctx_t *,\n> @@ -638,6 +638,8 @@ int parse_options(int argc, const char **argv, const char *prefix,\n>  \tcase PARSE_OPT_HELP:\n>  \tcase PARSE_OPT_ERROR:\n>  \t\texit(129);\n> +\tcase PARSE_OPT_COMPLETE:\n> +\t\texit(0);\n>  \tcase PARSE_OPT_NON_OPTION:\n>  \tcase PARSE_OPT_DONE:\n>  \t\tbreak;\n> diff --git a/parse-options.h b/parse-options.h\n> index 6c4fe2016d..a650a7d220 100644\n> --- a/parse-options.h\n> +++ b/parse-options.h\n> @@ -208,6 +208,7 @@ extern int opterror(const struct option *opt, const char *reason, int flags);\n>  /*----- incremental advanced APIs -----*/\n>  \n>  enum {\n> +\tPARSE_OPT_COMPLETE = -2,\n>  \tPARSE_OPT_HELP = -1,\n>  \tPARSE_OPT_DONE,\n>  \tPARSE_OPT_NON_OPTION,\n> -- 8< --\n"},{"id":"365087","messageId":"20181211153501.2169-1-pclouds@gmail.com","threadId":"47727","inReplyTo":"20181209102724.8707-1-pclouds@gmail.com","subject":"[PATCH v2] parse-options: fix SunCC compiler warning","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2018-12-11T15:35:01Z","receivedAt":"2018-12-11T15:35:13Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The compiler reports this because show_gitcomp() never actually\nreturns a value:\n\n    \"parse-options.c\", line 520: warning: Function has no return\n    statement : show_gitcomp\n\nWe could shut the compiler up. But instead let's not bury exit() too\ndeep. Do the same as internal -h handling, return a special error code\nand handle the exit() in parse_options() (and other\nparse_options_step() callers) instead.\n\nReported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/blame.c        | 2 ++\n builtin/shortlog.c     | 2 ++\n builtin/update-index.c | 2 ++\n parse-options.c        | 4 +++-\n parse-options.h        | 1 +\n 5 files changed, 10 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 06a7163ffe..6d798f9939 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -850,6 +850,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tcase PARSE_OPT_HELP:\n \t\tcase PARSE_OPT_ERROR:\n \t\t\texit(129);\n+\t\tcase PARSE_OPT_COMPLETE:\n+\t\t\texit(0);\n \t\tcase PARSE_OPT_DONE:\n \t\t\tif (ctx.argv[0])\n \t\t\t\tdashdash_pos = ctx.cpidx;\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 88f88e97b2..65cd41392c 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -287,6 +287,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)\n \t\tcase PARSE_OPT_HELP:\n \t\tcase PARSE_OPT_ERROR:\n \t\t\texit(129);\n+\t\tcase PARSE_OPT_COMPLETE:\n+\t\t\texit(0);\n \t\tcase PARSE_OPT_DONE:\n \t\t\tgoto parse_done;\n \t\t}\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 31e7cce301..e19da77edc 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -1086,6 +1086,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tcase PARSE_OPT_HELP:\n \t\tcase PARSE_OPT_ERROR:\n \t\t\texit(129);\n+\t\tcase PARSE_OPT_COMPLETE:\n+\t\t\texit(0);\n \t\tcase PARSE_OPT_NON_OPTION:\n \t\tcase PARSE_OPT_DONE:\n \t\t{\ndiff --git a/parse-options.c b/parse-options.c\nindex 3b874a83a0..6932eaff61 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -516,7 +516,7 @@ static int show_gitcomp(struct parse_opt_ctx_t *ctx,\n \tshow_negated_gitcomp(original_opts, -1);\n \tshow_negated_gitcomp(original_opts, nr_noopts);\n \tfputc('\\n', stdout);\n-\texit(0);\n+\treturn PARSE_OPT_COMPLETE;\n }\n \n static int usage_with_options_internal(struct parse_opt_ctx_t *,\n@@ -638,6 +638,8 @@ int parse_options(int argc, const char **argv, const char *prefix,\n \tcase PARSE_OPT_HELP:\n \tcase PARSE_OPT_ERROR:\n \t\texit(129);\n+\tcase PARSE_OPT_COMPLETE:\n+\t\texit(0);\n \tcase PARSE_OPT_NON_OPTION:\n \tcase PARSE_OPT_DONE:\n \t\tbreak;\ndiff --git a/parse-options.h b/parse-options.h\nindex 6c4fe2016d..a650a7d220 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -208,6 +208,7 @@ extern int opterror(const struct option *opt, const char *reason, int flags);\n /*----- incremental advanced APIs -----*/\n \n enum {\n+\tPARSE_OPT_COMPLETE = -2,\n \tPARSE_OPT_HELP = -1,\n \tPARSE_OPT_DONE,\n \tPARSE_OPT_NON_OPTION,\n-- \n2.20.0.481.gca8ed29094\n\n"},{"id":"365088","messageId":"CACsJy8BFn7xbJO8G_mTeeHBbZ3J52ZQkSAyrmyxe=BfVaapPEA@mail.gmail.com","threadId":"47727","inReplyTo":"xmqqk1kgn73c.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] parse-options: fix SunCC compiler warning","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-12-11T15:40:20Z","receivedAt":"2018-12-11T15:40:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Dec 11, 2018 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Duy Nguyen <pclouds@gmail.com> writes:\n>\n> > The reason it's in parse_options_step() is because -h is also handled\n> > in there. Although -h does not bury exit() deep in the call chain. So\n> > how about this as a replacement?\n>\n> So just like -h returns PARSE_OPT_HELP and causes the calling\n> parse_options() to exit(129), the new _COMPLETE can be used to\n> trigger an early & successful return?\n>\n> We'd also have to cover builtin/{blame,shortlog,update-index}.c\n> where they switch() on the return value from parse_options_step(),\n> but other than that, it probably is a better approach.  The users of\n> parse_options_step() that avoid parse_options() want to handle the\n> various \"we stopped by hitting a non-option\" cases in their own\n> ways, so treating this special action the same way as -h is treated\n> would be sensible.\n\nYeah, I saw that shortly after sending the patch.\n\n> We _might_ want to standardize some of the case\n> arms in these custom switch statements that appear in these three\n> built-in command implementations, but that can be done more easily\n> if this step is done like you showed below, I think.\n\nI have a better plan: stop exposing parse-options loop to outside.\nWhat all these commands need is the ability to deal with unknown\noptions (or non-options in update-index case). They could register\ncallbacks to deal with those and keep calling parse_options() instead.\nI'm converting rev-list to use parse_options() and as an intermediate\nstep, this callback idea should work well. The end game though is a\nsingle parse_options() call that covers everything in, say, git-log.\nBut we will see.\n-- \nDuy\n"},{"id":"365159","messageId":"xmqq4lbjji8z.fsf@gitster-ct.c.googlers.com","threadId":"47727","inReplyTo":"CACsJy8BFn7xbJO8G_mTeeHBbZ3J52ZQkSAyrmyxe=BfVaapPEA@mail.gmail.com","subject":"Re: [PATCH] parse-options: fix SunCC compiler warning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-12T07:50:52Z","receivedAt":"2018-12-12T07:50:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> I have a better plan: stop exposing parse-options loop to outside.\n> What all these commands need is the ability to deal with unknown\n> options (or non-options in update-index case). They could register\n> callbacks to deal with those and keep calling parse_options() instead.\n> I'm converting rev-list to use parse_options() and as an intermediate\n> step, this callback idea should work well. The end game though is a\n> single parse_options() call that covers everything in, say, git-log.\n> But we will see.\n\nSounds like a good plan.\n\nThanks.\n"}]}