{"thread":{"id":"64528","subject":"[PATCH] Add completion for short options","startedAt":"2025-11-25T06:39:01Z","lastAt":"2025-12-07T00:38:11Z","messageCount":7,"participants":["Wiktor Mis via GitGitGadget","Junio C Hamano","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"531252","messageId":"pull.2100.git.git.1764052739534.gitgitgadget@gmail.com","threadId":"64528","inReplyTo":null,"subject":"[PATCH] Add completion for short options","fromName":"Wiktor Mis via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-25T06:38:59Z","receivedAt":"2025-11-25T06:39:01Z","isPatch":true,"sender":{"key":"name:Wiktor Mis","avatar":null},"body":"From: Wiktor Mis <mwiktor023@gmail.com>\n\nGit provided completion for long options but not the short ones\n\nSigned-off-by: Wiktor Mis <mwiktor023@gmail.com>\n---\n    Add completion for short options\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2100%2FWiktorro%2Fpatch-3-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2100/Wiktorro/patch-3-v1\nPull-Request: https://github.com/git/git/pull/2100\n\n contrib/completion/git-completion.bash | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 73abea31b4..3f1d6c0955 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -3916,6 +3916,16 @@ __git_main ()\n \t\t\t--help\n \t\t\t\"\n \t\t\t;;\n+\t\t-*)\n+\t\t\t__gitcomp \"\n+\t\t\t-C\n+\t\t\t-P\n+\t\t\t-c\n+\t\t\t-h\n+\t\t\t-p\n+\t\t\t-v\n+\t\t\t\"\n+\t\t\t;;\n \t\t*)\n \t\t\tif test -n \"${GIT_TESTING_PORCELAIN_COMMAND_LIST-}\"\n \t\t\tthen\n\nbase-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72\n-- \ngitgitgadget\n"},{"id":"531261","messageId":"xmqq5xayt66k.fsf@gitster.g","threadId":"64528","inReplyTo":"pull.2100.git.git.1764052739534.gitgitgadget@gmail.com","subject":"Re: [PATCH] Add completion for short options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-25T16:42:27Z","receivedAt":"2025-11-25T16:42:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Wiktor Mis via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\nAs the large part of the completion script is about completing git\nsubcommands and options to these subcommands, it seems that nobody\nnoticed the lack of completion for options of \"git\" itself.\n\n> Subject: Re: [PATCH] Add completion for short options\n\nThis title makes it appear much broader than what the patch does,\nwhich is to complete \"git -<TAB>\" with short options for the \"git\"\npotty.\n\n    Subjct: [PATCH] completion: complete \"git -<TAB>\" with short options\n\nperhaps.\n\n> From: Wiktor Mis <mwiktor023@gmail.com>\n>\n> Git provided completion for long options but not the short ones\n\nComplete the sentence with something like\n\n    ... not the short ones for \"git\" itself.\n\n> Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>\n> ---\n>     Add completion for short options\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2100%2FWiktorro%2Fpatch-3-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2100/Wiktorro/patch-3-v1\n> Pull-Request: https://github.com/git/git/pull/2100\n>\n>  contrib/completion/git-completion.bash | 10 ++++++++++\n>  1 file changed, 10 insertions(+)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 73abea31b4..3f1d6c0955 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -3916,6 +3916,16 @@ __git_main ()\n>  \t\t\t--help\n>  \t\t\t\"\n>  \t\t\t;;\n> +\t\t-*)\n> +\t\t\t__gitcomp \"\n> +\t\t\t-C\n> +\t\t\t-P\n> +\t\t\t-c\n> +\t\t\t-h\n> +\t\t\t-p\n> +\t\t\t-v\n> +\t\t\t\"\n> +\t\t\t;;\n\nWhen you type\n\n    $ git -<TAB>\n\nthe current completion without this patch does nothing.  The above\nchange makes it instead show the listed six.\n\nWhich is a good enough incremental update, I guess.\n\nI however wonder if a separate follow-up change to let\n\n    $ git -<TAB>\n\nto show completion for both short and long options make the world\neven a better place.  With the current completion, even with this\npatch, you need to type double-dash-and-TAB to ask for list of long\noptions.\n\nThanks, will queue.\n"},{"id":"531310","messageId":"pull.2100.v2.git.git.1764174391776.gitgitgadget@gmail.com","threadId":"64528","inReplyTo":"pull.2100.git.git.1764052739534.gitgitgadget@gmail.com","subject":"[PATCH v2] completion: complete \"git -<TAB>\" with short options","fromName":"Wiktor Mis via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-26T16:26:31Z","receivedAt":"2025-11-26T16:26:35Z","isPatch":true,"sender":{"key":"name:Wiktor Mis","avatar":null},"body":"From: Wiktor Mis <mwiktor023@gmail.com>\n\n\"git\" itself has completion for long options and cmds, but not short ones\n\nSigned-off-by: Wiktor Mis <mwiktor023@gmail.com>\n---\n    Add completion for short options\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2100%2FWiktorro%2Fpatch-3-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2100/Wiktorro/patch-3-v2\nPull-Request: https://github.com/git/git/pull/2100\n\nRange-diff vs v1:\n\n 1:  1b15a0b458 ! 1:  e6161ffe3b Add completion for short options\n     @@ Metadata\n      Author: Wiktor Mis <mwiktor023@gmail.com>\n      \n       ## Commit message ##\n     -    Add completion for short options\n     +    completion: complete \"git -<TAB>\" with short options\n      \n     -    Git provided completion for long options but not the short ones\n     +    \"git\" itself has completion for long options and cmds, but not short ones\n      \n          Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>\n      \n       ## contrib/completion/git-completion.bash ##\n      @@ contrib/completion/git-completion.bash: __git_main ()\n     - \t\t\t--help\n     - \t\t\t\"\n       \t\t\t;;\n     + \t\tesac\n     + \t\tcase \"$cur\" in\n     +-\t\t--*)\n      +\t\t-*)\n     -+\t\t\t__gitcomp \"\n     + \t\t\t__gitcomp \"\n     + \t\t\t--paginate\n     + \t\t\t--no-pager\n     +@@ contrib/completion/git-completion.bash: __git_main ()\n     + \t\t\t--namespace=\n     + \t\t\t--no-replace-objects\n     + \t\t\t--help\n      +\t\t\t-C\n      +\t\t\t-P\n      +\t\t\t-c\n      +\t\t\t-h\n      +\t\t\t-p\n      +\t\t\t-v\n     -+\t\t\t\"\n     -+\t\t\t;;\n     + \t\t\t\"\n     + \t\t\t;;\n       \t\t*)\n     - \t\t\tif test -n \"${GIT_TESTING_PORCELAIN_COMMAND_LIST-}\"\n     - \t\t\tthen\n\n\n contrib/completion/git-completion.bash | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 73abea31b4..1705ca3323 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -3898,7 +3898,7 @@ __git_main ()\n \t\t\t;;\n \t\tesac\n \t\tcase \"$cur\" in\n-\t\t--*)\n+\t\t-*)\n \t\t\t__gitcomp \"\n \t\t\t--paginate\n \t\t\t--no-pager\n@@ -3914,6 +3914,12 @@ __git_main ()\n \t\t\t--namespace=\n \t\t\t--no-replace-objects\n \t\t\t--help\n+\t\t\t-C\n+\t\t\t-P\n+\t\t\t-c\n+\t\t\t-h\n+\t\t\t-p\n+\t\t\t-v\n \t\t\t\"\n \t\t\t;;\n \t\t*)\n\nbase-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72\n-- \ngitgitgadget\n"},{"id":"531331","messageId":"xmqqh5ugmu8d.fsf@gitster.g","threadId":"64528","inReplyTo":"pull.2100.v2.git.git.1764174391776.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] completion: complete \"git -<TAB>\" with short options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-26T20:09:22Z","receivedAt":"2025-11-26T20:09:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Wiktor Mis via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Wiktor Mis <mwiktor023@gmail.com>\n>\n> \"git\" itself has completion for long options and cmds, but not short ones\n>\n> Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>\n> ---\n>     Add completion for short options\n\nWill queue with a slight update to the log message.  I am unsure if\nwe want to limit \"-<TAB>\" to one-letter options or if we want to\ninclude the long ones (the latter is what v2 implements), but let's\nsee if others have strong opinions.\n\n    completion: complete \"git -<TAB>\" with short options\n\n    \"git\" itself has completion for its long options and subcommands,\n    but not for its short options.  Add support for them.\n\n    Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nThanks.\n\n>  contrib/completion/git-completion.bash | 8 +++++++-\n>  1 file changed, 7 insertions(+), 1 deletion(-)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 73abea31b4..1705ca3323 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -3898,7 +3898,7 @@ __git_main ()\n>  \t\t\t;;\n>  \t\tesac\n>  \t\tcase \"$cur\" in\n> -\t\t--*)\n> +\t\t-*)\n>  \t\t\t__gitcomp \"\n>  \t\t\t--paginate\n>  \t\t\t--no-pager\n> @@ -3914,6 +3914,12 @@ __git_main ()\n>  \t\t\t--namespace=\n>  \t\t\t--no-replace-objects\n>  \t\t\t--help\n> +\t\t\t-C\n> +\t\t\t-P\n> +\t\t\t-c\n> +\t\t\t-h\n> +\t\t\t-p\n> +\t\t\t-v\n>  \t\t\t\"\n>  \t\t\t;;\n>  \t\t*)\n>\n> base-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72\n"},{"id":"531369","messageId":"aSf+yrfJo8dRIkSo@szeder.dev","threadId":"64528","inReplyTo":"xmqqh5ugmu8d.fsf@gitster.g","subject":"Re: [PATCH v2] completion: complete \"git -<TAB>\" with short options","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2025-11-27T07:33:30Z","receivedAt":"2025-11-27T07:33:35Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Wed, Nov 26, 2025 at 12:09:22PM -0800, Junio C Hamano wrote:\n> \"Wiktor Mis via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> \n> > From: Wiktor Mis <mwiktor023@gmail.com>\n> >\n> > \"git\" itself has completion for long options and cmds, but not short ones\n> >\n> > Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>\n> > ---\n> >     Add completion for short options\n> \n> Will queue with a slight update to the log message.  I am unsure if\n> we want to limit \"-<TAB>\" to one-letter options or if we want to\n> include the long ones (the latter is what v2 implements), but let's\n> see if others have strong opinions.\n> \n>     completion: complete \"git -<TAB>\" with short options\n> \n>     \"git\" itself has completion for its long options and subcommands,\n>     but not for its short options.  Add support for them.\n\nIt's not just git itself that doesn't have completion for its short\noptions, but the completion script in general doesn't complete the\nshort options for anything.  The reason being, I think, that it\ndoesn't save keystrokes and it doesn't really help discoverability\n(Well, okay, strictly speaking it does help discoverability in the\nsense that 'git -<TAB>' will show the existence of short options, but\nsince short options don't have self-explanatory names, the users won't\nknow what those short options are good for.  E.g. I just learned from\nthis patch that the main git command accepts -p and -P options, but I\nhave no idea what they are doing.)\n\nSo overall I'm somewhat negative on this patch and in general on the\ndirection it takes us, but if we do want to go in this direction, then\nit will definitely need more justification than this.\n\n>     Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>\n>     Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> \n> Thanks.\n> \n> >  contrib/completion/git-completion.bash | 8 +++++++-\n> >  1 file changed, 7 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> > index 73abea31b4..1705ca3323 100644\n> > --- a/contrib/completion/git-completion.bash\n> > +++ b/contrib/completion/git-completion.bash\n> > @@ -3898,7 +3898,7 @@ __git_main ()\n> >  \t\t\t;;\n> >  \t\tesac\n> >  \t\tcase \"$cur\" in\n> > -\t\t--*)\n> > +\t\t-*)\n> >  \t\t\t__gitcomp \"\n> >  \t\t\t--paginate\n> >  \t\t\t--no-pager\n> > @@ -3914,6 +3914,12 @@ __git_main ()\n> >  \t\t\t--namespace=\n> >  \t\t\t--no-replace-objects\n> >  \t\t\t--help\n> > +\t\t\t-C\n> > +\t\t\t-P\n> > +\t\t\t-c\n> > +\t\t\t-h\n> > +\t\t\t-p\n> > +\t\t\t-v\n> >  \t\t\t\"\n> >  \t\t\t;;\n> >  \t\t*)\n> >\n> > base-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72\n"},{"id":"531385","messageId":"xmqqo6onjfwl.fsf@gitster.g","threadId":"64528","inReplyTo":"aSf+yrfJo8dRIkSo@szeder.dev","subject":"Re: [PATCH v2] completion: complete \"git -<TAB>\" with short options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-27T21:59:22Z","receivedAt":"2025-11-27T21:59:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> know what those short options are good for.  E.g. I just learned from\n> this patch that the main git command accepts -p and -P options, but I\n> have no idea what they are doing.)\n>\n> So overall I'm somewhat negative on this patch and in general on the\n> direction it takes us, but if we do want to go in this direction, then\n> it will definitely need more justification than this.\n\nAh, yes, I totally forgot earlier discussions we had long ago, e.g.,\n\n  https://lore.kernel.org/git/20070205024704.GB12917@spearce.org/\n\nCompleting potential values for a single letter short option is one\nthihng, but completing single letter short options themselves,\nunless the completion script can offer a short-help somehow, e.g.,\n\n    $ git -<TAB><TAB>\n    -C (chdir there before running the command)\n    -p (enable pager)\n    ...\n\nI agree that it would not be of much use.\n"},{"id":"531786","messageId":"xmqqh5u3nn2n.fsf@gitster.g","threadId":"64528","inReplyTo":"xmqqo6onjfwl.fsf@gitster.g","subject":"Re: [PATCH v2] completion: complete \"git -<TAB>\" with short options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-07T00:38:08Z","receivedAt":"2025-12-07T00:38:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> SZEDER Gábor <szeder.dev@gmail.com> writes:\n>\n>> know what those short options are good for.  E.g. I just learned from\n>> this patch that the main git command accepts -p and -P options, but I\n>> have no idea what they are doing.)\n>>\n>> So overall I'm somewhat negative on this patch and in general on the\n>> direction it takes us, but if we do want to go in this direction, then\n>> it will definitely need more justification than this.\n>\n> Ah, yes, I totally forgot earlier discussions we had long ago, e.g.,\n>\n>   https://lore.kernel.org/git/20070205024704.GB12917@spearce.org/\n>\n> Completing potential values for a single letter short option is one\n> thihng, but completing single letter short options themselves,\n> unless the completion script can offer a short-help somehow, e.g.,\n>\n>     $ git -<TAB><TAB>\n>     -C (chdir there before running the command)\n>     -p (enable pager)\n>     ...\n>\n> I agree that it would not be of much use.\n\nWe did not see any more comments on this thread during my vacation\n;-) so let me declare that we will discard this topic.\n\nThanks everybody for particupating, and thanks Wiktor for attempting\nto make Git a better system.\n\n"}]}