* [PATCH] bash completion: add basic support for git-reflog
@ 2010-11-20 17:32 Tay Ray Chuan
2010-11-22 15:24 ` SZEDER Gábor
0 siblings, 1 reply; 5+ messages in thread
From: Tay Ray Chuan @ 2010-11-20 17:32 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Shawn O. Pearce
Add basic completion for the three subcommands - show, expire, delete.
Try completing refs for these too.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
contrib/completion/git-completion.bash | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index f710469..4007ca1 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1632,6 +1632,22 @@ _git_rebase ()
__gitcomp "$(__git_refs)"
}
+_git_reflog ()
+{
+ local SUB_CMDS=(show delete expire)
+ local cur="${COMP_WORDS[COMP_CWORD-1]}"
+
+ for val in ${SUB_CMDS[*]}; do
+ if [[ "$val" == "$cur" ]]; then
+ # this is a subcommand
+ __gitcomp "$(__git_refs)"
+ return
+ fi
+ done
+
+ __gitcomp "${SUB_CMDS[*]}"
+}
+
__git_send_email_confirm_options="always never auto cc compose"
__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
--
1.7.3.2.496.g9c54
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] bash completion: add basic support for git-reflog
2010-11-20 17:32 [PATCH] bash completion: add basic support for git-reflog Tay Ray Chuan
@ 2010-11-22 15:24 ` SZEDER Gábor
2010-11-22 15:50 ` Tay Ray Chuan
0 siblings, 1 reply; 5+ messages in thread
From: SZEDER Gábor @ 2010-11-22 15:24 UTC (permalink / raw)
To: Tay Ray Chuan; +Cc: Git Mailing List, Junio C Hamano, Shawn O. Pearce
Hi,
On Sun, Nov 21, 2010 at 01:32:48AM +0800, Tay Ray Chuan wrote:
> Add basic completion for the three subcommands - show, expire, delete.
> Try completing refs for these too.
Heh, I've always thought reflog is plumbing, and that's why the
completion script doesn't support it.
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
> ---
> contrib/completion/git-completion.bash | 16 ++++++++++++++++
> 1 files changed, 16 insertions(+), 0 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index f710469..4007ca1 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1632,6 +1632,22 @@ _git_rebase ()
> __gitcomp "$(__git_refs)"
> }
>
> +_git_reflog ()
> +{
> + local SUB_CMDS=(show delete expire)
> + local cur="${COMP_WORDS[COMP_CWORD-1]}"
> +
> + for val in ${SUB_CMDS[*]}; do
> + if [[ "$val" == "$cur" ]]; then
> + # this is a subcommand
> + __gitcomp "$(__git_refs)"
> + return
This only looks at the previous word on the command line, and leads to
wrong behavior when an option is used:
$ git reflog expire --verbose <TAB><TAB>
delete expire show
To prevent this you could use the __git_find_on_cmdline() helper
function and follow how other completion functions use it.
> + fi
> + done
> +
> + __gitcomp "${SUB_CMDS[*]}"
> +}
> +
> __git_send_email_confirm_options="always never auto cc compose"
> __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
>
> --
> 1.7.3.2.496.g9c54
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bash completion: add basic support for git-reflog
2010-11-22 15:24 ` SZEDER Gábor
@ 2010-11-22 15:50 ` Tay Ray Chuan
2010-11-22 17:09 ` Tay Ray Chuan
0 siblings, 1 reply; 5+ messages in thread
From: Tay Ray Chuan @ 2010-11-22 15:50 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: Git Mailing List, Junio C Hamano, Shawn O. Pearce
Hi,
2010/11/22 SZEDER Gábor <szeder@ira.uka.de>:
> On Sun, Nov 21, 2010 at 01:32:48AM +0800, Tay Ray Chuan wrote:
>> Add basic completion for the three subcommands - show, expire, delete.
>> Try completing refs for these too.
>
> Heh, I've always thought reflog is plumbing, and that's why the
> completion script doesn't support it.
That didn't really cross my mind, I just did this out of my irritation
with its absence.
(After some checking, it's actually part of git-log, so I don't think
it counts as plumbing.)
> This only looks at the previous word on the command line, and leads to
> wrong behavior when an option is used:
>
> $ git reflog expire --verbose <TAB><TAB>
> delete expire show
>
> To prevent this you could use the __git_find_on_cmdline() helper
> function and follow how other completion functions use it.
Yep I'll look into it.
--
Cheers,
Ray Chuan
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] bash completion: add basic support for git-reflog
2010-11-22 15:50 ` Tay Ray Chuan
@ 2010-11-22 17:09 ` Tay Ray Chuan
2010-11-22 17:20 ` Jonathan Nieder
0 siblings, 1 reply; 5+ messages in thread
From: Tay Ray Chuan @ 2010-11-22 17:09 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Shawn O. Pearce, SZEDER Gabor
"Promote" the reflog command out of plumbing, so that we now run
completion for it. After all, it's listed under porcelain (ancillary),
and we do run completion for those commands.
Add basic completion for the three subcommands - show, expire, delete.
Try completing refs for these too.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
Changed from v1:
- picked up Gábor's suggestion on using __git_find_on_cmdline()
to correctly handle situations where subcommands are used with dashed
options.
- don't "hide" reflog anymore - run completion for it too.
Gábor: hmm, it really seems that reflog is treated as plumbing - no completion
is done for it. Even get-tar-commit-id (I've never used this before) is treated
better than reflog. Shall do something about it!
contrib/completion/git-completion.bash | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index f710469..6732b1d 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -735,7 +735,6 @@ __git_list_porcelain_commands ()
quiltimport) : import;;
read-tree) : plumbing;;
receive-pack) : plumbing;;
- reflog) : plumbing;;
remote-*) : transport;;
repo-config) : deprecated;;
rerere) : plumbing;;
@@ -1632,6 +1631,18 @@ _git_rebase ()
__gitcomp "$(__git_refs)"
}
+_git_reflog ()
+{
+ local subcommands="show delete expire"
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ else
+ __gitcomp "$(__git_refs)"
+ fi
+}
+
__git_send_email_confirm_options="always never auto cc compose"
__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
--
1.7.3.2.493.g2b058
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] bash completion: add basic support for git-reflog
2010-11-22 17:09 ` Tay Ray Chuan
@ 2010-11-22 17:20 ` Jonathan Nieder
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Nieder @ 2010-11-22 17:20 UTC (permalink / raw)
To: Tay Ray Chuan
Cc: Git Mailing List, Junio C Hamano, Shawn O. Pearce, SZEDER Gabor
Tay Ray Chuan wrote:
> Gábor: hmm, it really seems that reflog is treated as plumbing - no completion
> is done for it.
Probably because it is listed as such in command-list.txt. I guess
the user-facing command for reflog expiration is meant to be "git gc"?
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1632,6 +1631,18 @@ _git_rebase ()
> __gitcomp "$(__git_refs)"
> }
>
> +_git_reflog ()
> +{
> + local subcommands="show delete expire"
People really do seem to use these commands directly, so I'm all for
this.
I wish there were a way to easily point the end user from "git reflog
show" to "git log --walk-reflogs" (to make the list of other accepted
options more obvious) but I can't think of one.
Regards,
Jonathan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-11-22 17:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-20 17:32 [PATCH] bash completion: add basic support for git-reflog Tay Ray Chuan
2010-11-22 15:24 ` SZEDER Gábor
2010-11-22 15:50 ` Tay Ray Chuan
2010-11-22 17:09 ` Tay Ray Chuan
2010-11-22 17:20 ` Jonathan Nieder
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).