Subject: Re: [PATCH v2] completion: complete "git -<TAB>" with short options

From: Junio C Hamano <[email-masked]>
Date: Wed, 26 Nov 2025 12:09:22 -0800

"Wiktor Mis via GitGitGadget" <[email-masked]> writes:

> From: Wiktor Mis <[email-masked]>
>
> "git" itself has completion for long options and cmds, but not short ones
>
> Signed-off-by: Wiktor Mis <[email-masked]>
> ---
>     Add completion for short options

Will queue with a slight update to the log message.  I am unsure if
we want to limit "-<TAB>" to one-letter options or if we want to
include the long ones (the latter is what v2 implements), but let's
see if others have strong opinions.

    completion: complete "git -<TAB>" with short options

    "git" itself has completion for its long options and subcommands,
    but not for its short options.  Add support for them.

    Signed-off-by: Wiktor Mis <[email-masked]>
    Signed-off-by: Junio C Hamano <[email-masked]>

Thanks.

>  contrib/completion/git-completion.bash | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 73abea31b4..1705ca3323 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -3898,7 +3898,7 @@ __git_main ()
>  			;;
>  		esac
>  		case "$cur" in
> -		--*)
> +		-*)
>  			__gitcomp "
>  			--paginate
>  			--no-pager
> @@ -3914,6 +3914,12 @@ __git_main ()
>  			--namespace=
>  			--no-replace-objects
>  			--help
> +			-C
> +			-P
> +			-c
> +			-h
> +			-p
> +			-v
>  			"
>  			;;
>  		*)
>
> base-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72