* [PATCH v2 0/4] Fix branch.autosetup(merge|rebase) completion @ 2014-01-03 8:00 Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 1/4] completion: prioritize ./git-completion.bash Ramkumar Ramachandra ` (3 more replies) 0 siblings, 4 replies; 8+ messages in thread From: Ramkumar Ramachandra @ 2014-01-03 8:00 UTC (permalink / raw) To: Git List; +Cc: Junio C Hamano Hi, In this iteration, I've removed hunks to prevent completing: $ git config remote.pushdefault.<TAB> $ git config branch.autosetupmerge.<TAB> $ git config branch.autosetuprebase.<TAB> Since they're perfectly valid remote/ branch names. Thanks. Ramkumar Ramachandra (4): completion: prioritize ./git-completion.bash completion: introduce __gitcomp_2 () completion: fix branch.autosetup(merge|rebase) completion: fix remote.pushdefault contrib/completion/git-completion.bash | 36 ++++++++++++++++++++++++++++++++-- contrib/completion/git-completion.zsh | 12 +++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) -- 1.8.5.2.227.g53f3478 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/4] completion: prioritize ./git-completion.bash 2014-01-03 8:00 [PATCH v2 0/4] Fix branch.autosetup(merge|rebase) completion Ramkumar Ramachandra @ 2014-01-03 8:00 ` Ramkumar Ramachandra 2014-01-03 22:55 ` brian m. carlson 2014-01-03 8:00 ` [PATCH v2 2/4] completion: introduce __gitcomp_2 () Ramkumar Ramachandra ` (2 subsequent siblings) 3 siblings, 1 reply; 8+ messages in thread From: Ramkumar Ramachandra @ 2014-01-03 8:00 UTC (permalink / raw) To: Git List; +Cc: Junio C Hamano To ease development, prioritize ./git-completion.bash over other standard system paths. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- contrib/completion/git-completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index fac5e71..6fca145 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -30,10 +30,10 @@ if [ -z "$script" ]; then local -a locations local e locations=( + $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash '/etc/bash_completion.d/git' # fedora, old debian '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian '/usr/share/bash-completion/git' # gentoo - $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash ) for e in $locations; do test -f $e && script="$e" && break -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/4] completion: prioritize ./git-completion.bash 2014-01-03 8:00 ` [PATCH v2 1/4] completion: prioritize ./git-completion.bash Ramkumar Ramachandra @ 2014-01-03 22:55 ` brian m. carlson 2014-01-03 23:03 ` Junio C Hamano 2014-01-05 10:08 ` Ramkumar Ramachandra 0 siblings, 2 replies; 8+ messages in thread From: brian m. carlson @ 2014-01-03 22:55 UTC (permalink / raw) To: Ramkumar Ramachandra; +Cc: Git List, Junio C Hamano [-- Attachment #1: Type: text/plain, Size: 1533 bytes --] On Fri, Jan 03, 2014 at 01:30:28PM +0530, Ramkumar Ramachandra wrote: > To ease development, prioritize ./git-completion.bash over other > standard system paths. > > Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> > --- > contrib/completion/git-completion.zsh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh > index fac5e71..6fca145 100644 > --- a/contrib/completion/git-completion.zsh > +++ b/contrib/completion/git-completion.zsh > @@ -30,10 +30,10 @@ if [ -z "$script" ]; then > local -a locations > local e > locations=( > + $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash > '/etc/bash_completion.d/git' # fedora, old debian > '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian > '/usr/share/bash-completion/git' # gentoo > - $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash > ) > for e in $locations; do > test -f $e && script="$e" && break I'm not clear on this change. It looks like this loads git-completion.bash from the same directory as git-completion.zsh. Is this correct? Your commit message says "./", and if that's the case, it has the same security problems as putting "." first in your PATH. -- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187 [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/4] completion: prioritize ./git-completion.bash 2014-01-03 22:55 ` brian m. carlson @ 2014-01-03 23:03 ` Junio C Hamano 2014-01-05 10:08 ` Ramkumar Ramachandra 1 sibling, 0 replies; 8+ messages in thread From: Junio C Hamano @ 2014-01-03 23:03 UTC (permalink / raw) To: brian m. carlson; +Cc: Ramkumar Ramachandra, Git List "brian m. carlson" <sandals@crustytoothpaste.net> writes: > On Fri, Jan 03, 2014 at 01:30:28PM +0530, Ramkumar Ramachandra wrote: >> To ease development, prioritize ./git-completion.bash over other >> standard system paths. >> >> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> >> --- >> contrib/completion/git-completion.zsh | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh >> index fac5e71..6fca145 100644 >> --- a/contrib/completion/git-completion.zsh >> +++ b/contrib/completion/git-completion.zsh >> @@ -30,10 +30,10 @@ if [ -z "$script" ]; then >> local -a locations >> local e >> locations=( >> + $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash >> '/etc/bash_completion.d/git' # fedora, old debian >> '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian >> '/usr/share/bash-completion/git' # gentoo >> - $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash >> ) >> for e in $locations; do >> test -f $e && script="$e" && break > > I'm not clear on this change. It looks like this loads > git-completion.bash from the same directory as git-completion.zsh. Is > this correct? I think the idea is to help those who have installed a closer to bleeding-edge version of completion scripts --- they will not be reading their zsh completions from the system default locations, and the place next to it would be a place more likely to have the matching bleeding-edge version of bash completion than the system default place. > Your commit message says "./", and if that's the case, it > has the same security problems as putting "." first in your PATH. A correct observation. I think Subject: zsh completion: find matching custom bash completion If zsh completion is being read from a location that is different from system-wide default, it is likely that the user is trying to use a custom version, perhaps closer to the bleeding edge, installed in her own directory. We will more likely to find the matching bash completion script in the same directory than in those system default places. would probably a lot closer to what the patch really does. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/4] completion: prioritize ./git-completion.bash 2014-01-03 22:55 ` brian m. carlson 2014-01-03 23:03 ` Junio C Hamano @ 2014-01-05 10:08 ` Ramkumar Ramachandra 1 sibling, 0 replies; 8+ messages in thread From: Ramkumar Ramachandra @ 2014-01-05 10:08 UTC (permalink / raw) To: Ramkumar Ramachandra, Git List, Junio C Hamano brian m. carlson wrote: > I'm not clear on this change. It looks like this loads > git-completion.bash from the same directory as git-completion.zsh. Is > this correct? Yes, and that's what I meant to convey with the "./". Junio's message is clearer though, so I'll use that. Thanks. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/4] completion: introduce __gitcomp_2 () 2014-01-03 8:00 [PATCH v2 0/4] Fix branch.autosetup(merge|rebase) completion Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 1/4] completion: prioritize ./git-completion.bash Ramkumar Ramachandra @ 2014-01-03 8:00 ` Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 3/4] completion: fix branch.autosetup(merge|rebase) Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 4/4] completion: fix remote.pushdefault Ramkumar Ramachandra 3 siblings, 0 replies; 8+ messages in thread From: Ramkumar Ramachandra @ 2014-01-03 8:00 UTC (permalink / raw) To: Git List; +Cc: Junio C Hamano There are situations where two classes of completions possible. For example branch.<TAB> should try to complete branch.master. branch.autosetupmerge branch.autosetuprebase The first candidate has the suffix ".", and the second/ third candidates have the suffix " ". To facilitate completions of this kind, create a variation of __gitcomp_nl () that accepts two sets of arguments and two independent suffixes. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- contrib/completion/git-completion.bash | 30 ++++++++++++++++++++++++++++++ contrib/completion/git-completion.zsh | 10 ++++++++++ 2 files changed, 40 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 51c2dd4..64b20b8 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -233,6 +233,36 @@ __gitcomp_nl () __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" } +# Generates completion reply from two sets of completion words, with +# configurable suffixes for each. +# +# It accepts 2 to 6 arguments: +# 1: First set of possible completion words. +# 2: Second set of possible completion words. +# 3: A prefix to be added to each completion word (both $1 and $2) +# (optional). +# 4: Generate possible completion matches for this word (optional). +# 5: A suffix to be appended to each completion word in the first set +# ($1) instead of the default space (optional). +# 6: A suffix to be appended to each completion word in the second set +# ($2) instead of the default space (optional). +__gitcomp_2 () +{ + local pfx="${3-}" cur_="${4-$cur}" sfx="${5- }" sfx2="${6- }" i=0 + local IFS=$' \t\n' + + for x in $1; do + if [[ "$x" == "$cur_"* ]]; then + COMPREPLY[i++]="$pfx$x$sfx" + fi + done + for x in $2; do + if [[ "$x" == "$cur_"* ]]; then + COMPREPLY[i++]="$pfx$x$sfx2" + fi + done +} + # Generates completion reply with compgen from newline-separated possible # completion filenames. # It accepts 1 to 3 arguments: diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 6fca145..261a7f5 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -76,6 +76,16 @@ __gitcomp_nl () compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 } +__gitcomp_2 () +{ + emulate -L zsh + + local IFS=$' \t\n' + compset -P '*[=:]' + compadd -Q -S "${5- }" -p "${3-}" -- ${=1} && _ret=0 + compadd -Q -S "${6- }" -p "${3-}" -- ${=2} && _ret=0 +} + __gitcomp_file () { emulate -L zsh -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/4] completion: fix branch.autosetup(merge|rebase) 2014-01-03 8:00 [PATCH v2 0/4] Fix branch.autosetup(merge|rebase) completion Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 1/4] completion: prioritize ./git-completion.bash Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 2/4] completion: introduce __gitcomp_2 () Ramkumar Ramachandra @ 2014-01-03 8:00 ` Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 4/4] completion: fix remote.pushdefault Ramkumar Ramachandra 3 siblings, 0 replies; 8+ messages in thread From: Ramkumar Ramachandra @ 2014-01-03 8:00 UTC (permalink / raw) To: Git List; +Cc: Junio C Hamano When attempting to complete $ git config branch.auto<TAB> 'autosetupmerge' and 'autosetuprebase' don't come up. This is because "$cur" is matched with "branch.*" and a list of branches are completed. Add 'autosetup(merge|rebase)' to the list of branches using __gitcomp_2 (). Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- contrib/completion/git-completion.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 64b20b8..cbb4eca 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1856,7 +1856,9 @@ _git_config () ;; branch.*) local pfx="${cur%.*}." cur_="${cur#*.}" - __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "." + __gitcomp_2 "$(__git_heads)" " + autosetupmerge autosetuprebase + " "$pfx" "$cur_" "." return ;; guitool.*.*) -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/4] completion: fix remote.pushdefault 2014-01-03 8:00 [PATCH v2 0/4] Fix branch.autosetup(merge|rebase) completion Ramkumar Ramachandra ` (2 preceding siblings ...) 2014-01-03 8:00 ` [PATCH v2 3/4] completion: fix branch.autosetup(merge|rebase) Ramkumar Ramachandra @ 2014-01-03 8:00 ` Ramkumar Ramachandra 3 siblings, 0 replies; 8+ messages in thread From: Ramkumar Ramachandra @ 2014-01-03 8:00 UTC (permalink / raw) To: Git List; +Cc: Junio C Hamano When attempting to complete $ git config remote.push<TAB> 'pushdefault' doesn't come up. This is because "$cur" is matched with "remote.*" and a list of remotes are completed. Add 'pushdefault' to the list of remotes using __gitcomp_2 (). Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index cbb4eca..04d72a1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1900,7 +1900,7 @@ _git_config () ;; remote.*) local pfx="${cur%.*}." cur_="${cur#*.}" - __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." + __gitcomp_2 "$(__git_remotes)" "pushdefault" "$pfx" "$cur_" "." return ;; url.*.*) -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-01-05 10:17 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-01-03 8:00 [PATCH v2 0/4] Fix branch.autosetup(merge|rebase) completion Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 1/4] completion: prioritize ./git-completion.bash Ramkumar Ramachandra 2014-01-03 22:55 ` brian m. carlson 2014-01-03 23:03 ` Junio C Hamano 2014-01-05 10:08 ` Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 2/4] completion: introduce __gitcomp_2 () Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 3/4] completion: fix branch.autosetup(merge|rebase) Ramkumar Ramachandra 2014-01-03 8:00 ` [PATCH v2 4/4] completion: fix remote.pushdefault Ramkumar Ramachandra
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).