return
;;
--*)
- __gitcomp_builtin am "--no-utf8" \
+ __gitcomp_builtin am "" \
"$__git_am_inprogress_options"
return
esac
__git_complete_refs --cur="${cur##--set-upstream-to=}"
;;
--*)
- __gitcomp_builtin branch "--no-color --no-abbrev
- --no-track --no-column
- "
+ __gitcomp_builtin branch
;;
*)
if [ $only_local_ref = "y" -a $has_r = "n" ]; then
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--*)
- __gitcomp_builtin checkout "--no-track --no-recurse-submodules"
+ __gitcomp_builtin checkout
;;
*)
# check if --track, --no-track, or --no-guess was specified
{
case "$cur" in
--*)
- __gitcomp_builtin clone "--no-single-branch"
+ __gitcomp_builtin clone
return
;;
esac
return
;;
--*)
- __gitcomp_builtin commit "--no-edit --verify"
+ __gitcomp_builtin commit
return
esac
return
;;
--*)
- __gitcomp_builtin fetch "--no-tags"
+ __gitcomp_builtin fetch
return
;;
esac
{
case "$cur" in
--*)
- __gitcomp_builtin fsck "--no-reflogs"
+ __gitcomp_builtin fsck
return
;;
esac
{
case "$cur" in
--*)
- __gitcomp_builtin ls-files "--no-empty-directory"
+ __gitcomp_builtin ls-files
return
;;
esac
case "$cur" in
--*)
- __gitcomp_builtin merge "--no-rerere-autoupdate
- --no-commit --no-edit --no-ff
- --no-log --no-progress
- --no-squash --no-stat
- --no-verify-signatures
- "
+ __gitcomp_builtin merge
return
esac
__git_complete_refs
return
;;
--*)
- __gitcomp_builtin pull "--no-autostash --no-commit --no-edit
- --no-ff --no-log --no-progress --no-rebase
- --no-squash --no-stat --no-tags
- --no-verify-signatures"
+ __gitcomp_builtin pull
return
;;
return
;;
--*)
- __gitcomp_builtin status "--no-column"
+ __gitcomp_builtin status
return
;;
esac
case "$subcommand,$cur" in
add,--*)
- __gitcomp_builtin remote_add "--no-tags"
+ __gitcomp_builtin remote_add
;;
add,*)
;;
fi
case "$cur" in
--*)
- __gitcomp_builtin revert "--no-edit" \
+ __gitcomp_builtin revert "" \
"$__git_revert_inprogress_options"
return
;;
{
case "$cur" in
--*)
- __gitcomp_builtin show-branch "--no-color"
+ __gitcomp_builtin show-branch
return
;;
esac
parse_options_check(options);
}
-/*
- * TODO: we are not completing the --no-XXX form yet because there are
- * many options that do not suppress it properly.
- */
static int show_gitcomp(struct parse_opt_ctx_t *ctx,
const struct option *opts)
{
for (; opts->type != OPTION_END; opts++) {
const char *suffix = "";
+ int has_unset_form = 0;
if (!opts->long_name)
continue;
case OPTION_INTEGER:
case OPTION_MAGNITUDE:
case OPTION_CALLBACK:
+ has_unset_form = 1;
+
if (opts->flags & PARSE_OPT_NOARG)
break;
if (opts->flags & PARSE_OPT_OPTARG)
break;
suffix = "=";
break;
+ case OPTION_BIT:
+ case OPTION_NEGBIT:
+ case OPTION_COUNTUP:
+ case OPTION_SET_INT:
+ has_unset_form = 1;
+ break;
default:
break;
}
if (opts->flags & PARSE_OPT_COMP_ARG)
suffix = "=";
printf(" --%s%s", opts->long_name, suffix);
+
+ if (has_unset_form && !(opts->flags & PARSE_OPT_NONEG)) {
+ const char *name;
+
+ if (skip_prefix(opts->long_name, "no-", &name))
+ printf(" --%s", name);
+ else
+ printf(" --no-%s", opts->long_name);
+ }
}
fputc('\n', stdout);
exit(0);
test_expect_success 'double dash "git checkout"' '
test_completion "git checkout --" <<-\EOF
--quiet Z
+ --no-quiet Z
--detach Z
+ --no-detach Z
--track Z
+ --no-track Z
--orphan=Z
+ --no-orphan Z
--ours Z
+ --no-ours Z
--theirs Z
+ --no-theirs Z
--merge Z
+ --no-merge Z
--conflict=Z
+ --no-conflict Z
--patch Z
+ --no-patch Z
--ignore-skip-worktree-bits Z
+ --no-ignore-skip-worktree-bits Z
--ignore-other-worktrees Z
+ --no-ignore-other-worktrees Z
--recurse-submodules Z
- --progress Z
- --no-track Z
--no-recurse-submodules Z
+ --progress Z
+ --no-progress Z
EOF
'
test_expect_success 'completion without explicit _git_xxx function' '
test_completion "git version --" <<-\EOF
--build-options Z
+ --no-build-options Z
EOF
'