{"thread":{"id":"49146","subject":"Incomplete bash completion on git commit: --allow-empty-message and --allow-empty","startedAt":"2018-08-16T07:46:57Z","lastAt":"2018-08-17T14:48:15Z","messageCount":5,"participants":["Hadi Safari","Duy Nguyen","Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"355817","messageId":"69624916-f6ba-d4a4-e346-69498662905e@hadisafari.ir","threadId":"49146","inReplyTo":null,"subject":"Incomplete bash completion on git commit: --allow-empty-message and --allow-empty","fromName":"Hadi Safari","fromEmail":"hadi@hadisafari.ir","sentAt":"2018-08-16T07:46:51Z","receivedAt":"2018-08-16T07:46:57Z","isPatch":false,"sender":{"key":"hadi@hadisafari.ir","avatar":null},"body":"Hi!\n\nI'm wondering why there isn't --allow-empty and --allow-empty-message in \ncompleteion list of git commit command. I'm getting only following flags \nfrom v2.18.0 on `git commit --`:\n\n--ahead-behind      --include           --reedit-message=\n--all               --interactive       --reset-author\n--amend             --long              --reuse-message=\n--author=           --message=          --short\n--branch            --no-edit           --signoff\n--cleanup=          --no-post-rewrite   --squash=\n--date=             --no-verify         --status\n--dry-run           --null              --template=\n--edit              --only              --untracked-files\n--file=             --patch             --verbose\n--fixup=            --porcelain         --verify\n--gpg-sign          --quiet\n\nBesides, is there any way to allow empty commit message for a repo, e.g. \nby adding something to `.git/config`? I couldn't find any in docs.\n\n-- \nHadi\n"},{"id":"355837","messageId":"CACsJy8At828KS_U+CzhujtJXn9Ma+p4fbmTm-72XsS28Hj62oQ@mail.gmail.com","threadId":"49146","inReplyTo":"69624916-f6ba-d4a4-e346-69498662905e@hadisafari.ir","subject":"Re: Incomplete bash completion on git commit: --allow-empty-message and --allow-empty","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-08-16T15:10:17Z","receivedAt":"2018-08-16T15:10:48Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Aug 16, 2018 at 3:50 PM Hadi Safari <hadi@hadisafari.ir> wrote:\n>\n> Hi!\n>\n> I'm wondering why there isn't --allow-empty and --allow-empty-message in\n> completeion list of git commit command.\n\nThis is because they are marked \"hidden\" in the code. If you do \"git\ncommit -h\", they will not show up either. Ævar provided the reason for\nhiding them in c9b5fde759 (Add option to git-commit to allow empty log\nmessages - 2010-04-06), basically \"not for normal use\" so it makes\nsense to not complete them. If they are used often on command line\nnow, then of course we need to reconsider to stop hiding them.\n-- \nDuy\n"},{"id":"355838","messageId":"20180816151125.11803-1-avarab@gmail.com","threadId":"49146","inReplyTo":"69624916-f6ba-d4a4-e346-69498662905e@hadisafari.ir","subject":"[PATCH] completion: include PARSE_OPT_HIDDEN in completion output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-08-16T15:11:25Z","receivedAt":"2018-08-16T15:11:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The PARSE_OPT_HIDDEN is, per the documentation of the \"option\" struct\nin option parse-options.h, only supposed to affect -h output, not\ncompletion. That's what the PARSE_OPT_NOCOMPLETE flag is supposed to\nbe for.\n\nSince 2e29dca66a (\"completion: use __gitcomp_builtin in _git_commit\",\n2018-02-09) we've been using e.g. \"git commit --git-completion-helper\"\nto get the bash completion for the git-commit command. Due to\nPARSE_OPT_HIDDEN this excluded e.g. --allow-empty and\n--allow-empty-message.\n\nNow, this wasn't a behavior change in that commit. Before that we had\na hardcoded list of options, removed in 2e29dca66a (\"completion: use\n__gitcomp_builtin in _git_commit\", 2018-02-09). This list didn't\ncontain those two options.\n\nBut as noted in the follow-up discussion to c9b5fde759 (\"Add option to\ngit-commit to allow empty log messages\", 2010-04-06) in\nhttps://public-inbox.org/git/20100406055530.GE3901@coredump.intra.peff.net/\nthe motivation for PARSE_OPT_HIDDEN was to keep the \"git commit -h\"\noutput to a minimum, not to hide it from completion.\n\nI think it makes sense to exclude options like these from -h output,\nbut for the completion the user is usually not trying to complete \"git\ncommit --<TAB>\", but e.g. \"git commit --allo<TAB>\", and because of\nthis behavior we don't show these options at all there.\n\nHowever, manually going over:\n\n    git grep -e OPT_HIDDEN_BOOL -e PARSE_OPT_HIDDEN\n\nShows many options we don't want to show in completion either,\ne.g. \"git am --binary\" or \"git branch -l\". Many of these are internal,\ndeprecated, or no-ops. There's also things like \"git difftool\n--prompt\" (the default behavior) which are arguably pointless to add,\nwe just have \"--no-prompt\" to inverse the default.\n\nThe options we'll now show on completion, that we didn't show before,\nare:\n\nOPT_HIDDEN_BOOL:\n\n * checkout: --guess (no idea how this works, not documented, but it's\n   not deprecated and is there..)\n * commit: --allow-empty and --allow-empty-message\n * help: --exclude-guides (because why not?)\n * receive-pack: All three (non --quiet) options it supports. It\n   doesn't have any completion now, but if we ever add it why not\n   complete these?\n\nPARSE_OPT_HIDDEN (without PARSE_OPT_NOCOMPLETE):\n\n * fetch: --recurse-submodules-default (a legitimate documented\n   option, but perhaps we should blacklist this because it's rarely\n   used and interferes with --recurse-submodules?).\n * ls-remote: --exec (as with \"fetch\" this is a synonym for\n   --upload-pack, but unlike \"fetch\" it wasn't documented. Document it\n   while I'm at it).\n\nI don't know if that \"o->flags |= PARSE_OPT_HIDDEN\" line in\ncmd_parseopt() in builtin/rev-parse.c should also be setting\nPARSE_OPT_NOCOMPLETE.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n\nOn Thu, Aug 16, 2018 at 9:46 AM, Hadi Safari <hadi@hadisafari.ir> wrote:\n>\n> Hi!\n>\n> I'm wondering why there isn't --allow-empty and\n> --allow-empty-message in completeion list of git commit command. I'm\n> getting only following flags from v2.18.0 on `git commit --`:\n\nIt's because we've been conflating the desire to include something in\n\"git <cmd> -h\" output, and having \"git <cmd> --some-rare-option\" work\nor not. Here's an attempt to fix it.\n\n Documentation/git-ls-remote.txt | 3 +++\n archive.c                       | 3 ++-\n builtin/add.c                   | 5 +++--\n builtin/am.c                    | 8 ++++----\n builtin/branch.c                | 5 +++--\n builtin/clone.c                 | 8 ++++----\n builtin/difftool.c              | 4 ++--\n builtin/fetch.c                 | 3 ++-\n builtin/fmt-merge-msg.c         | 3 ++-\n builtin/grep.c                  | 2 +-\n builtin/help.c                  | 2 +-\n builtin/name-rev.c              | 3 ++-\n builtin/pull.c                  | 2 +-\n builtin/show-ref.c              | 4 ++--\n builtin/write-tree.c            | 4 ++--\n parse-options.c                 | 4 ++--\n parse-options.h                 | 3 +++\n t/t9902-completion.sh           | 1 +\n 18 files changed, 40 insertions(+), 27 deletions(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex b9fd3770a6..39192f4e2a 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -43,6 +43,9 @@ OPTIONS\n \tSSH and where the SSH daemon does not use the PATH configured by the\n \tuser.\n \n+--exec=<git-upload-pack>::\n+\tSame as --upload-pack=<git-upload-pack>.\n+\n --exit-code::\n \tExit with status \"2\" when no matching refs are found in the remote\n \trepository. Usually the command exits with status \"0\" to indicate\ndiff --git a/archive.c b/archive.c\nindex 78b0a398a0..d5e02127a1 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -414,7 +414,8 @@ static void parse_treeish_arg(const char **argv,\n #define OPT__COMPR(s, v, h, p) \\\n \tOPT_SET_INT_F(s, NULL, v, h, p, PARSE_OPT_NONEG)\n #define OPT__COMPR_HIDDEN(s, v, p) \\\n-\tOPT_SET_INT_F(s, NULL, v, \"\", p, PARSE_OPT_NONEG | PARSE_OPT_HIDDEN)\n+\tOPT_SET_INT_F(s, NULL, v, \"\", p, \\\n+\tPARSE_OPT_NONEG | PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE)\n \n static int parse_archive_args(int argc, const char **argv,\n \t\tconst struct archiver **ar, struct archiver_args *args,\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 8a155dd41e..f283eda6d8 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -305,8 +305,9 @@ static struct option builtin_add_options[] = {\n \tOPT_BOOL( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n \tOPT_BOOL( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n \tOPT_STRING( 0 , \"chmod\", &chmod_arg, N_(\"(+/-)x\"), N_(\"override the executable bit of the listed files\")),\n-\tOPT_HIDDEN_BOOL(0, \"warn-embedded-repo\", &warn_on_embedded_repo,\n-\t\t\tN_(\"warn when adding an embedded repository\")),\n+\tOPT_HIDDEN_NOCOMPLETE_BOOL(0, \"warn-embedded-repo\",\n+\t\t\t\t   &warn_on_embedded_repo,\n+\t\t\t\t   N_(\"warn when adding an embedded repository\")),\n \tOPT_END(),\n };\n \ndiff --git a/builtin/am.c b/builtin/am.c\nindex 2c19e69f58..d5353c5954 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -2215,8 +2215,8 @@ int cmd_am(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT_BOOL('i', \"interactive\", &state.interactive,\n \t\t\tN_(\"run interactively\")),\n-\t\tOPT_HIDDEN_BOOL('b', \"binary\", &binary,\n-\t\t\tN_(\"historical option -- no-op\")),\n+\t\tOPT_HIDDEN_NOCOMPLETE_BOOL('b', \"binary\", &binary,\n+\t\t\t\t\t   N_(\"historical option -- no-op\")),\n \t\tOPT_BOOL('3', \"3way\", &state.threeway,\n \t\t\tN_(\"allow fall back on 3way merging if needed\")),\n \t\tOPT__QUIET(&state.quiet, N_(\"be quiet\")),\n@@ -2298,8 +2298,8 @@ int cmd_am(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_STRING, 'S', \"gpg-sign\", &state.sign_commit, N_(\"key-id\"),\n \t\t  N_(\"GPG-sign commits\"),\n \t\t  PARSE_OPT_OPTARG, NULL, (intptr_t) \"\" },\n-\t\tOPT_HIDDEN_BOOL(0, \"rebasing\", &state.rebasing,\n-\t\t\tN_(\"(internal use for git-rebase)\")),\n+\t\tOPT_HIDDEN_NOCOMPLETE_BOOL(0, \"rebasing\", &state.rebasing,\n+\t\t\t\t\t   N_(\"(internal use for git-rebase)\")),\n \t\tOPT_END()\n \t};\n \ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 4fc55c3508..366ffb175d 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -598,7 +598,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT('t', \"track\",  &track, N_(\"set up tracking mode (see git-pull(1))\"),\n \t\t\tBRANCH_TRACK_EXPLICIT),\n \t\tOPT_SET_INT_F(0, \"set-upstream\", &track, N_(\"do not use\"),\n-\t\t\tBRANCH_TRACK_OVERRIDE, PARSE_OPT_HIDDEN),\n+\t\t\t      BRANCH_TRACK_OVERRIDE,\n+\t\t\t      PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE),\n \t\tOPT_STRING('u', \"set-upstream-to\", &new_upstream, N_(\"upstream\"), N_(\"change the upstream info\")),\n \t\tOPT_BOOL(0, \"unset-upstream\", &unset_upstream, N_(\"Unset the upstream info\")),\n \t\tOPT__COLOR(&branch_use_color, N_(\"use colored output\")),\n@@ -624,7 +625,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\t{\n \t\t\tOPTION_CALLBACK, 'l', NULL, &reflog, NULL,\n \t\t\tN_(\"deprecated synonym for --create-reflog\"),\n-\t\t\tPARSE_OPT_NOARG | PARSE_OPT_HIDDEN,\n+\t\t\tPARSE_OPT_NOARG | PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE,\n \t\t\tdeprecated_reflog_option_cb\n \t\t},\n \t\tOPT_BOOL(0, \"edit-description\", &edit_description,\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex fd2c3ef090..27d2a1a459 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -87,8 +87,8 @@ static struct option builtin_clone_options[] = {\n \tOPT_BOOL('n', \"no-checkout\", &option_no_checkout,\n \t\t N_(\"don't create a checkout\")),\n \tOPT_BOOL(0, \"bare\", &option_bare, N_(\"create a bare repository\")),\n-\tOPT_HIDDEN_BOOL(0, \"naked\", &option_bare,\n-\t\t\tN_(\"create a bare repository\")),\n+\tOPT_HIDDEN_NOCOMPLETE_BOOL(0, \"naked\", &option_bare,\n+\t\t\t\t   N_(\"create a bare repository\")),\n \tOPT_BOOL(0, \"mirror\", &option_mirror,\n \t\t N_(\"create a mirror repository (implies bare)\")),\n \tOPT_BOOL('l', \"local\", &option_local,\n@@ -99,8 +99,8 @@ static struct option builtin_clone_options[] = {\n \t\t    N_(\"setup as shared repository\")),\n \t{ OPTION_CALLBACK, 0, \"recursive\", &option_recurse_submodules,\n \t  N_(\"pathspec\"), N_(\"initialize submodules in the clone\"),\n-\t  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, recurse_submodules_cb,\n-\t  (intptr_t)\".\" },\n+\t  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE,\n+\t  recurse_submodules_cb, (intptr_t)\".\" },\n \t{ OPTION_CALLBACK, 0, \"recurse-submodules\", &option_recurse_submodules,\n \t  N_(\"pathspec\"), N_(\"initialize submodules in the clone\"),\n \t  PARSE_OPT_OPTARG, recurse_submodules_cb, (intptr_t)\".\" },\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 3018e61d04..f63e866dd7 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -699,8 +699,8 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT_F('y', \"no-prompt\", &prompt,\n \t\t\tN_(\"do not prompt before launching a diff tool\"),\n \t\t\t0, PARSE_OPT_NONEG),\n-\t\tOPT_SET_INT_F(0, \"prompt\", &prompt, NULL,\n-\t\t\t1, PARSE_OPT_NONEG | PARSE_OPT_HIDDEN),\n+\t\tOPT_SET_INT_F(0, \"prompt\", &prompt, NULL, 1,\n+\t\t\t      PARSE_OPT_NONEG | PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"symlinks\", &symlinks,\n \t\t\t N_(\"use symlinks in dir-diff mode\")),\n \t\tOPT_STRING('t', \"tool\", &difftool_cmd, N_(\"<tool>\"),\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 61bec5d213..3f11d743ee 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -153,7 +153,8 @@ static struct option builtin_fetch_options[] = {\n \t\t   &recurse_submodules_default, N_(\"on-demand\"),\n \t\t   N_(\"default for recursive fetching of submodules \"\n \t\t      \"(lower priority than config files)\"),\n-\t\t   PARSE_OPT_HIDDEN, option_fetch_parse_recurse_submodules },\n+\t\t   PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE,\n+\t\t   option_fetch_parse_recurse_submodules },\n \tOPT_BOOL(0, \"update-shallow\", &update_shallow,\n \t\t N_(\"accept refs that update .git/shallow\")),\n \t{ OPTION_CALLBACK, 0, \"refmap\", NULL, N_(\"refmap\"),\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex f35ff1612b..ba0a8426a0 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -672,7 +672,8 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)\n \t\t  PARSE_OPT_OPTARG, NULL, DEFAULT_MERGE_LOG_LEN },\n \t\t{ OPTION_INTEGER, 0, \"summary\", &shortlog_len, N_(\"n\"),\n \t\t  N_(\"alias for --log (deprecated)\"),\n-\t\t  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, NULL,\n+\t\t  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE,\n+\t\t  NULL,\n \t\t  DEFAULT_MERGE_LOG_LEN },\n \t\tOPT_STRING('m', \"message\", &message, N_(\"text\"),\n \t\t\tN_(\"use <text> as start of message\")),\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex ee5a1bd355..2ecd941101 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -892,7 +892,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"show only matches from files that match all patterns\")),\n \t\tOPT_SET_INT_F(0, \"debug\", &opt.debug,\n \t\t\t      N_(\"show parse tree for grep expression\"),\n-\t\t\t      1, PARSE_OPT_HIDDEN),\n+\t\t\t      1, PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE),\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\"),\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 8d4f6dd301..90c7a85cba 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -47,7 +47,7 @@ static struct option builtin_help_options[] = {\n \tOPT_HIDDEN_BOOL(0, \"exclude-guides\", &exclude_guides, N_(\"exclude guides\")),\n \tOPT_BOOL('g', \"guides\", &show_guides, N_(\"print list of useful guides\")),\n \tOPT_BOOL('c', \"config\", &show_config, N_(\"print all configuration variable names\")),\n-\tOPT_SET_INT_F(0, \"config-for-completion\", &show_config, \"\", 2, PARSE_OPT_HIDDEN),\n+\tOPT_SET_INT_F(0, \"config-for-completion\", &show_config, \"\", 2, PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE),\n \tOPT_SET_INT('m', \"man\", &help_format, N_(\"show man page\"), HELP_FORMAT_MAN),\n \tOPT_SET_INT('w', \"web\", &help_format, N_(\"show manual in web browser\"),\n \t\t\tHELP_FORMAT_WEB),\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex f1cb45c227..0a63d23761 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -426,7 +426,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\t/* A Hidden OPT_BOOL */\n \t\t\tOPTION_SET_INT, 0, \"peel-tag\", &peel_tag, NULL,\n \t\t\tN_(\"dereference tags in the input (internal use)\"),\n-\t\t\tPARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1,\n+\t\t\tPARSE_OPT_NOARG | PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE,\n+\t\t\tNULL, 1,\n \t\t},\n \t\tOPT_END(),\n \t};\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 4e78935392..cdc67cd17f 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -146,7 +146,7 @@ static struct option pull_options[] = {\n \t\tPARSE_OPT_NOARG),\n \tOPT_PASSTHRU(0, \"summary\", &opt_diffstat, NULL,\n \t\tN_(\"(synonym to --stat)\"),\n-\t\tPARSE_OPT_NOARG | PARSE_OPT_HIDDEN),\n+\t\tPARSE_OPT_NOARG | PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE),\n \tOPT_PASSTHRU(0, \"log\", &opt_log, N_(\"n\"),\n \t\tN_(\"add (at most <n>) entries from shortlog to merge commit message\"),\n \t\tPARSE_OPT_OPTARG),\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 2f13f1316f..afd916fa06 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -161,8 +161,8 @@ static const struct option show_ref_options[] = {\n \tOPT_BOOL(0, \"heads\", &heads_only, N_(\"only show heads (can be combined with tags)\")),\n \tOPT_BOOL(0, \"verify\", &verify, N_(\"stricter reference checking, \"\n \t\t    \"requires exact ref path\")),\n-\tOPT_HIDDEN_BOOL('h', NULL, &show_head,\n-\t\t\tN_(\"show the HEAD reference, even if it would be filtered out\")),\n+\tOPT_HIDDEN_NOCOMPLETE_BOOL('h', NULL, &show_head,\n+\t\t\t\t   N_(\"show the HEAD reference, even if it would be filtered out\")),\n \tOPT_BOOL(0, \"head\", &show_head,\n \t  N_(\"show the HEAD reference, even if it would be filtered out\")),\n \tOPT_BOOL('d', \"dereference\", &deref_tags,\ndiff --git a/builtin/write-tree.c b/builtin/write-tree.c\nindex c9d3c544e7..489a5e46b0 100644\n--- a/builtin/write-tree.c\n+++ b/builtin/write-tree.c\n@@ -29,8 +29,8 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)\n \t\t  PARSE_OPT_LITERAL_ARGHELP },\n \t\t{ OPTION_BIT, 0, \"ignore-cache-tree\", &flags, NULL,\n \t\t  N_(\"only useful for debugging\"),\n-\t\t  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, NULL,\n-\t\t  WRITE_TREE_IGNORE_CACHE_TREE },\n+\t\t  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG | PARSE_OPT_NOCOMPLETE,\n+\t\t  NULL, WRITE_TREE_IGNORE_CACHE_TREE },\n \t\tOPT_END()\n \t};\n \ndiff --git a/parse-options.c b/parse-options.c\nindex 7db84227ab..a9c82e518a 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -437,7 +437,7 @@ static void show_negated_gitcomp(const struct option *opts, int nr_noopts)\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_NOCOMPLETE)\n \t\t\tcontinue;\n \t\tif (opts->flags & PARSE_OPT_NONEG)\n \t\t\tcontinue;\n@@ -485,7 +485,7 @@ static int show_gitcomp(struct parse_opt_ctx_t *ctx,\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_NOCOMPLETE)\n \t\t\tcontinue;\n \n \t\tswitch (opts->type) {\ndiff --git a/parse-options.h b/parse-options.h\nindex dd14911a29..5f78e2e164 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -139,6 +139,9 @@ struct option {\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_HIDDEN_NOCOMPLETE_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \\\n+\t\t\t\t\t\t (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE, \\\n+\t\t\t\t\t\tNULL, 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_INTEGER(s, l, v, h)     { OPTION_INTEGER, (s), (l), (v), N_(\"n\"), (h) }\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 5ff43b9cbb..2e0b9c78e7 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -1423,6 +1423,7 @@ test_expect_success 'double dash \"git checkout\"' '\n \ttest_completion \"git checkout --\" <<-\\EOF\n \t--quiet Z\n \t--detach Z\n+\t--guess Z\n \t--track Z\n \t--orphan=Z\n \t--ours Z\n-- \n2.18.0.865.gffc8e1a3cd6\n\n"},{"id":"355843","messageId":"xmqq4lfugvjq.fsf@gitster-ct.c.googlers.com","threadId":"49146","inReplyTo":"20180816151125.11803-1-avarab@gmail.com","subject":"Re: [PATCH] completion: include PARSE_OPT_HIDDEN in completion output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-08-16T15:50:33Z","receivedAt":"2018-08-16T15:50:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> However, manually going over:\n>\n>     git grep -e OPT_HIDDEN_BOOL -e PARSE_OPT_HIDDEN\n>\n> Shows many options we don't want to show in completion either,\n> e.g. \"git am --binary\" or \"git branch -l\". Many of these are internal,\n> deprecated, or no-ops. There's also things like \"git difftool\n> --prompt\" (the default behavior) which are arguably pointless to add,\n> we just have \"--no-prompt\" to inverse the default.\n\nYeah, and I believe some hidden ones are hidden because they\nencourage bad workflows (like --allow-empty-message) especially when\nused interactively, and they aren't marked with nocomplete only\nbecause there wasn't any such bit back when they were marked hidden.\n\nIn any case, those that are hidden for such a reason now need to be\nmarked with both hidden and nocomplete, which is a small one-time\nprice to pay to make the meaning of these two bits saner.  So I\nquite like the direction in which this patch is taking the\nunderlying mechanism.\n\nA \"blind\" translation that is far safer than your patch may first\n\n * update the code so that ones with hidden-bit are completed\n\n * update the data so that ones currently have hidden bit but not\n   nocomplete bit gain nocomplete bit as well.\n\nThat would give us a saner mechanism without changing the behaviour.\n\nAnd then we can make policy decisions for each option separately for\nthe merit of keeping it hidden (i.e. excluding from short help to\nunclutter) and/or keeping it not completed (i.e. discouraging its\nuse in an interactive session).\n\nAs I think some of the hidden ones also have nocomplete and others\ndo not have nocomplete merely by historical accident, the way this\npatch changes behaviour for some options (namely, the hidden ones\nthat did not have nocomplete not because they wanted to be completed\nbut because there wasn't such an option to exclude them from\ncompletion previously and because it was sufficient to mark them as\nhidden to exclude them from completion) means making policy\ndecisions while updating the mechanism that allows us to express our\npolicy decisions.  I do not think we should conflate the two in the\nsame patch.\n"},{"id":"355908","messageId":"CACsJy8AtoftZL7dKCL2qpKvGHHcSXKj057CU3aCACUqUMgMp-g@mail.gmail.com","threadId":"49146","inReplyTo":"20180816151125.11803-1-avarab@gmail.com","subject":"Re: [PATCH] completion: include PARSE_OPT_HIDDEN in completion output","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-08-17T14:47:46Z","receivedAt":"2018-08-17T14:48:15Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Aug 16, 2018 at 8:42 PM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n>\n> The PARSE_OPT_HIDDEN is, per the documentation of the \"option\" struct\n> in option parse-options.h, only supposed to affect -h output, not\n> completion. That's what the PARSE_OPT_NOCOMPLETE flag is supposed to\n> be for.\n>\n> Since 2e29dca66a (\"completion: use __gitcomp_builtin in _git_commit\",\n> 2018-02-09) we've been using e.g. \"git commit --git-completion-helper\"\n> to get the bash completion for the git-commit command. Due to\n> PARSE_OPT_HIDDEN this excluded e.g. --allow-empty and\n> --allow-empty-message.\n>\n> Now, this wasn't a behavior change in that commit. Before that we had\n> a hardcoded list of options, removed in 2e29dca66a (\"completion: use\n> __gitcomp_builtin in _git_commit\", 2018-02-09). This list didn't\n> contain those two options.\n>\n> But as noted in the follow-up discussion to c9b5fde759 (\"Add option to\n> git-commit to allow empty log messages\", 2010-04-06) in\n> https://public-inbox.org/git/20100406055530.GE3901@coredump.intra.peff.net/\n> the motivation for PARSE_OPT_HIDDEN was to keep the \"git commit -h\"\n> output to a minimum, not to hide it from completion.\n>\n> I think it makes sense to exclude options like these from -h output,\n> but for the completion the user is usually not trying to complete \"git\n> commit --<TAB>\",\n\nActually I do :)\n\n> but e.g. \"git commit --allo<TAB>\", and because of this behavior we don't show these options at all there.\n\nAnd it would be great if these options do not show up at --<tab> but\ndo when with --a<tab>.\n\nWe already do something similar to this with --no-<tab>. So this could\nbe another option.\n-- \nDuy\n"}]}