* bash completion only provides revs, not paths
@ 2008-04-22 11:21 Uwe Kleine-König
2008-04-23 1:52 ` Shawn O. Pearce
0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2008-04-22 11:21 UTC (permalink / raw)
To: git; +Cc: Shawn O. Pearce
Hello,
currently autocompletion in
ukleinek@zentaur:~/gsrc/linux-2.6 git log ar<tab>
only yields "armltd/" (i.e. the prefix of some remote tracking branches)
but most of the time I want it to complete to "arch/".
I don't understand that autocompletion stuff, but probably to fix that
several __git_complete_revlist should be replaced by a
__git_complete_revlist_or_path. The harder part is to implement the
latter function. An optimal implementation would only give back paths
if there is a "--" somewhere before the cursor.
Best regards
Uwe
--
Uwe Kleine-König, Software Engineer
Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bash completion only provides revs, not paths
2008-04-22 11:21 bash completion only provides revs, not paths Uwe Kleine-König
@ 2008-04-23 1:52 ` Shawn O. Pearce
2008-04-23 5:56 ` Uwe Kleine-König
0 siblings, 1 reply; 5+ messages in thread
From: Shawn O. Pearce @ 2008-04-23 1:52 UTC (permalink / raw)
To: Uwe Kleine-Knig, Junio C Hamano; +Cc: git
Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com> wrote:
> currently autocompletion in
>
> ukleinek@zentaur:~/gsrc/linux-2.6 git log ar<tab>
>
> only yields "armltd/" (i.e. the prefix of some remote tracking branches)
> but most of the time I want it to complete to "arch/".
Right. It favors refs over paths. Why? Because I complete refs
more than I complete paths.
> I don't understand that autocompletion stuff, but probably to fix that
> several __git_complete_revlist should be replaced by a
> __git_complete_revlist_or_path. The harder part is to implement the
> latter function. An optimal implementation would only give back paths
> if there is a "--" somewhere before the cursor.
Its ugly, but if we only do path name completion after a -- then
we can just return "" as the options to bash, and it will go off
and do the path name completion itself. If we do path names and
and refs at the same time, that's a disaster waiting to happen.
We would have to do the path name completion ourselves.
How is this?
--8<--
bash completion: Completely only path names after -- in options
If the user has inserted a -- before the current argument we are
being asked to complete they are most likely trying to force Git into
treating this argument as a path name, and not as a ref. We should
allow bash to complete it as a path from the local working directory.
Suggested-by: Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
contrib/completion/git-completion.bash | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0f5d30c..8d8405e 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -308,7 +308,20 @@ __git_complete_file ()
__git_complete_revlist ()
{
- local pfx cur="${COMP_WORDS[COMP_CWORD]}"
+ local c=1 pfx cur
+
+ while [ $c -lt $COMP_CWORD ]; do
+ cur="${COMP_WORDS[c]}"
+ case "$cur" in
+ --)
+ COMPREPLY=()
+ return
+ ;;
+ esac
+ c=$((++c))
+ done
+
+ cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
*...*)
pfx="${cur%...*}..."
--
1.5.5.1.141.gd55b
--
Shawn.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: bash completion only provides revs, not paths
2008-04-23 1:52 ` Shawn O. Pearce
@ 2008-04-23 5:56 ` Uwe Kleine-König
2008-04-24 1:21 ` [PATCH] " Shawn O. Pearce
0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2008-04-23 5:56 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git
Hello Shawn,
Shawn O. Pearce wrote:
> Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com> wrote:
> > currently autocompletion in
> >
> > ukleinek@zentaur:~/gsrc/linux-2.6 git log ar<tab>
> >
> > only yields "armltd/" (i.e. the prefix of some remote tracking branches)
> > but most of the time I want it to complete to "arch/".
>
> Right. It favors refs over paths. Why? Because I complete refs
> more than I complete paths.
>
> > I don't understand that autocompletion stuff, but probably to fix that
> > several __git_complete_revlist should be replaced by a
> > __git_complete_revlist_or_path. The harder part is to implement the
> > latter function. An optimal implementation would only give back paths
> > if there is a "--" somewhere before the cursor.
>
> Its ugly, but if we only do path name completion after a -- then
> we can just return "" as the options to bash, and it will go off
> and do the path name completion itself. If we do path names and
> and refs at the same time, that's a disaster waiting to happen.
> We would have to do the path name completion ourselves.
I thought compgen can be used for that:
ukleinek@zentaur:~/gsrc/linux-2.6$ compgen -f ar
arch
> How is this?
I like it and have already applied it.
> --8<--
> bash completion: Completely only path names after -- in options
>
> If the user has inserted a -- before the current argument we are
> being asked to complete they are most likely trying to force Git into
> treating this argument as a path name, and not as a ref. We should
> allow bash to complete it as a path from the local working directory.
>
> Suggested-by: Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com>
There is a letter missing in my name. I wonder why it's always the only
non-ascii one :-)
Best regards and thanks,
Uwe
--
Uwe Kleine-König, Software Engineer
Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] bash completion only provides revs, not paths
2008-04-23 5:56 ` Uwe Kleine-König
@ 2008-04-24 1:21 ` Shawn O. Pearce
2008-04-24 5:52 ` Uwe Kleine-König
0 siblings, 1 reply; 5+ messages in thread
From: Shawn O. Pearce @ 2008-04-24 1:21 UTC (permalink / raw)
To: Uwe Kleine-König, Junio C Hamano; +Cc: git
Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com> wrote:
> > How is this?
>
> I like it and have already applied it.
...
> > Suggested-by: Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com>
>
> There is a letter missing in my name. I wonder why it's always the only
> non-ascii one :-)
Damn. I'm sorry. My mailer seems to be dropping it when I
quote you, and I copied your name from the "... wrote:" line
at the top of my message. I should have copied from the
To: header, where it hasn't been munged.
Fixed commit message below.
--8<--
bash completion: Completely only path names after -- in options
If the user has inserted a -- before the current argument we are
being asked to complete they are most likely trying to force Git into
treating this argument as a path name, and not as a ref. We should
allow bash to complete it as a path from the local working directory.
Tested-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
contrib/completion/git-completion.bash | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0f5d30c..8d8405e 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -308,7 +308,20 @@ __git_complete_file ()
__git_complete_revlist ()
{
- local pfx cur="${COMP_WORDS[COMP_CWORD]}"
+ local c=1 pfx cur
+
+ while [ $c -lt $COMP_CWORD ]; do
+ cur="${COMP_WORDS[c]}"
+ case "$cur" in
+ --)
+ COMPREPLY=()
+ return
+ ;;
+ esac
+ c=$((++c))
+ done
+
+ cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
*...*)
pfx="${cur%...*}..."
--
1.5.5.1.141.gd55b
--
Shawn.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] bash completion only provides revs, not paths
2008-04-24 1:21 ` [PATCH] " Shawn O. Pearce
@ 2008-04-24 5:52 ` Uwe Kleine-König
0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2008-04-24 5:52 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git
Hello,
Shawn O. Pearce wrote:
> Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com> wrote:
> > > How is this?
> >
> > I like it and have already applied it.
> ...
> > > Suggested-by: Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com>
> >
> > There is a letter missing in my name. I wonder why it's always the only
> > non-ascii one :-)
>
> Damn. I'm sorry. My mailer seems to be dropping it when I
> quote you, and I copied your name from the "... wrote:" line
> at the top of my message. I should have copied from the
> To: header, where it hasn't been munged.
Fine.
BTW, even with your patch the problem still exists for git-diff. I
havn't yet looked into it.
Uwe
--
Uwe Kleine-König, Software Engineer
Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-04-24 6:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-22 11:21 bash completion only provides revs, not paths Uwe Kleine-König
2008-04-23 1:52 ` Shawn O. Pearce
2008-04-23 5:56 ` Uwe Kleine-König
2008-04-24 1:21 ` [PATCH] " Shawn O. Pearce
2008-04-24 5:52 ` Uwe Kleine-König
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).