* [PATCH] Add completion for short options
@ 2025-11-25 6:38 Wiktor Mis via GitGitGadget
2025-11-25 16:42 ` Junio C Hamano
2025-11-26 16:26 ` [PATCH v2] completion: complete "git -<TAB>" with " Wiktor Mis via GitGitGadget
0 siblings, 2 replies; 7+ messages in thread
From: Wiktor Mis via GitGitGadget @ 2025-11-25 6:38 UTC (permalink / raw)
To: git; +Cc: Wiktor Mis, Wiktor Mis
From: Wiktor Mis <mwiktor023@gmail.com>
Git provided completion for long options but not the short ones
Signed-off-by: Wiktor Mis <mwiktor023@gmail.com>
---
Add completion for short options
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2100%2FWiktorro%2Fpatch-3-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2100/Wiktorro/patch-3-v1
Pull-Request: https://github.com/git/git/pull/2100
contrib/completion/git-completion.bash | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 73abea31b4..3f1d6c0955 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3916,6 +3916,16 @@ __git_main ()
--help
"
;;
+ -*)
+ __gitcomp "
+ -C
+ -P
+ -c
+ -h
+ -p
+ -v
+ "
+ ;;
*)
if test -n "${GIT_TESTING_PORCELAIN_COMMAND_LIST-}"
then
base-commit: fd372d9b1a69a01a676398882bbe3840bf51fe72
--
gitgitgadget
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] Add completion for short options 2025-11-25 6:38 [PATCH] Add completion for short options Wiktor Mis via GitGitGadget @ 2025-11-25 16:42 ` Junio C Hamano 2025-11-26 16:26 ` [PATCH v2] completion: complete "git -<TAB>" with " Wiktor Mis via GitGitGadget 1 sibling, 0 replies; 7+ messages in thread From: Junio C Hamano @ 2025-11-25 16:42 UTC (permalink / raw) To: Wiktor Mis via GitGitGadget; +Cc: git, Wiktor Mis "Wiktor Mis via GitGitGadget" <gitgitgadget@gmail.com> writes: As the large part of the completion script is about completing git subcommands and options to these subcommands, it seems that nobody noticed the lack of completion for options of "git" itself. > Subject: Re: [PATCH] Add completion for short options This title makes it appear much broader than what the patch does, which is to complete "git -<TAB>" with short options for the "git" potty. Subjct: [PATCH] completion: complete "git -<TAB>" with short options perhaps. > From: Wiktor Mis <mwiktor023@gmail.com> > > Git provided completion for long options but not the short ones Complete the sentence with something like ... not the short ones for "git" itself. > Signed-off-by: Wiktor Mis <mwiktor023@gmail.com> > --- > Add completion for short options > > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2100%2FWiktorro%2Fpatch-3-v1 > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2100/Wiktorro/patch-3-v1 > Pull-Request: https://github.com/git/git/pull/2100 > > contrib/completion/git-completion.bash | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash > index 73abea31b4..3f1d6c0955 100644 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -3916,6 +3916,16 @@ __git_main () > --help > " > ;; > + -*) > + __gitcomp " > + -C > + -P > + -c > + -h > + -p > + -v > + " > + ;; When you type $ git -<TAB> the current completion without this patch does nothing. The above change makes it instead show the listed six. Which is a good enough incremental update, I guess. I however wonder if a separate follow-up change to let $ git -<TAB> to show completion for both short and long options make the world even a better place. With the current completion, even with this patch, you need to type double-dash-and-TAB to ask for list of long options. Thanks, will queue. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] completion: complete "git -<TAB>" with short options 2025-11-25 6:38 [PATCH] Add completion for short options Wiktor Mis via GitGitGadget 2025-11-25 16:42 ` Junio C Hamano @ 2025-11-26 16:26 ` Wiktor Mis via GitGitGadget 2025-11-26 20:09 ` Junio C Hamano 1 sibling, 1 reply; 7+ messages in thread From: Wiktor Mis via GitGitGadget @ 2025-11-26 16:26 UTC (permalink / raw) To: git; +Cc: Wiktor Mis, Wiktor Mis 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 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2100%2FWiktorro%2Fpatch-3-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2100/Wiktorro/patch-3-v2 Pull-Request: https://github.com/git/git/pull/2100 Range-diff vs v1: 1: 1b15a0b458 ! 1: e6161ffe3b Add completion for short options @@ Metadata Author: Wiktor Mis <mwiktor023@gmail.com> ## Commit message ## - Add completion for short options + completion: complete "git -<TAB>" with short options - Git provided completion for long options but not the short ones + "git" itself has completion for long options and cmds, but not short ones Signed-off-by: Wiktor Mis <mwiktor023@gmail.com> ## contrib/completion/git-completion.bash ## @@ contrib/completion/git-completion.bash: __git_main () - --help - " ;; + esac + case "$cur" in +- --*) + -*) -+ __gitcomp " + __gitcomp " + --paginate + --no-pager +@@ contrib/completion/git-completion.bash: __git_main () + --namespace= + --no-replace-objects + --help + -C + -P + -c + -h + -p + -v -+ " -+ ;; + " + ;; *) - if test -n "${GIT_TESTING_PORCELAIN_COMMAND_LIST-}" - then 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 -- gitgitgadget ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] completion: complete "git -<TAB>" with short options 2025-11-26 16:26 ` [PATCH v2] completion: complete "git -<TAB>" with " Wiktor Mis via GitGitGadget @ 2025-11-26 20:09 ` Junio C Hamano 2025-11-27 7:33 ` SZEDER Gábor 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2025-11-26 20:09 UTC (permalink / raw) To: Wiktor Mis via GitGitGadget; +Cc: git, Wiktor Mis "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. 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] completion: complete "git -<TAB>" with short options 2025-11-26 20:09 ` Junio C Hamano @ 2025-11-27 7:33 ` SZEDER Gábor 2025-11-27 21:59 ` Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: SZEDER Gábor @ 2025-11-27 7:33 UTC (permalink / raw) To: Junio C Hamano; +Cc: Wiktor Mis via GitGitGadget, git, Wiktor Mis On Wed, Nov 26, 2025 at 12:09:22PM -0800, Junio C Hamano wrote: > "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. > 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] completion: complete "git -<TAB>" with short options 2025-11-27 7:33 ` SZEDER Gábor @ 2025-11-27 21:59 ` Junio C Hamano 2025-12-07 0:38 ` Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2025-11-27 21:59 UTC (permalink / raw) To: SZEDER Gábor; +Cc: Wiktor Mis via GitGitGadget, git, Wiktor Mis SZEDER Gábor <szeder.dev@gmail.com> writes: > 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. Ah, yes, I totally forgot earlier discussions we had long ago, e.g., https://lore.kernel.org/git/20070205024704.GB12917@spearce.org/ Completing potential values for a single letter short option is one thihng, but completing single letter short options themselves, unless the completion script can offer a short-help somehow, e.g., $ git -<TAB><TAB> -C (chdir there before running the command) -p (enable pager) ... I agree that it would not be of much use. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] completion: complete "git -<TAB>" with short options 2025-11-27 21:59 ` Junio C Hamano @ 2025-12-07 0:38 ` Junio C Hamano 0 siblings, 0 replies; 7+ messages in thread From: Junio C Hamano @ 2025-12-07 0:38 UTC (permalink / raw) To: SZEDER Gábor; +Cc: Wiktor Mis via GitGitGadget, git, Wiktor Mis Junio C Hamano <gitster@pobox.com> writes: > SZEDER Gábor <szeder.dev@gmail.com> writes: > >> 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. > > Ah, yes, I totally forgot earlier discussions we had long ago, e.g., > > https://lore.kernel.org/git/20070205024704.GB12917@spearce.org/ > > Completing potential values for a single letter short option is one > thihng, but completing single letter short options themselves, > unless the completion script can offer a short-help somehow, e.g., > > $ git -<TAB><TAB> > -C (chdir there before running the command) > -p (enable pager) > ... > > I agree that it would not be of much use. We did not see any more comments on this thread during my vacation ;-) so let me declare that we will discard this topic. Thanks everybody for particupating, and thanks Wiktor for attempting to make Git a better system. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-12-07 0:38 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-11-25 6:38 [PATCH] Add completion for short options Wiktor Mis via GitGitGadget 2025-11-25 16:42 ` Junio C Hamano 2025-11-26 16:26 ` [PATCH v2] completion: complete "git -<TAB>" with " Wiktor Mis via GitGitGadget 2025-11-26 20:09 ` Junio C Hamano 2025-11-27 7:33 ` SZEDER Gábor 2025-11-27 21:59 ` Junio C Hamano 2025-12-07 0:38 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).