git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Nov 27, 2025, 07:33 UTC
Message-ID
<aSf+yrfJo8dRIkSo@szeder.dev>
In-Reply-To
<xmqqh5ugmu8d.fsf@gitster.g>
On Wed, Nov 26, 2025 at 12:09:22PM -0800, Junio C Hamano wrote:
Show 19 quoted lines
> "Wiktor Mis via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> > From: Wiktor Mis <mwiktor023@gmail.com>
> >
> > "git" itself has completion for long options and cmds, but not short ones
> >
> > Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>
> > ---
> >     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.

It's not just git itself that doesn't have completion for its short options, but the completion script in general doesn't complete the short options for anything. The reason being, I think, that it doesn't save keystrokes and it doesn't really help discoverability (Well, okay, strictly speaking it does help discoverability in the sense that 'git -<TAB>' will show the existence of short options, but since short options don't have self-explanatory names, the users won't know what those short options are good for. E.g. I just learned from this patch that the main git command accepts -p and -P options, but I have no idea what they are doing.)

So overall I'm somewhat negative on this patch and in general on the direction it takes us, but if we do want to go in this direction, then it will definitely need more justification than this.

Show 36 quoted lines
>     Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>
>     Signed-off-by: Junio C Hamano <gitster@pobox.com>
> 
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 7 in “Add completion for short options”
  1. Add completion for short optionsWiktor Mis via GitGitGadget, Nov 25, 2025
  2. Junio C HamanoNov 25, 2025
  3. completion: complete "git -<TAB>" with short optionsWiktor Mis via GitGitGadget, Nov 26, 2025
  4. Junio C HamanoNov 26, 2025
  5. SZEDER GáborNov 27, 2025
  6. Junio C HamanoNov 27, 2025
  7. Junio C HamanoDec 7, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.