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 <redacted>
---
contrib/completion/git-completion.bash | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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 <redacted>
---
contrib/completion/git-completion.bash | 30 ++++++++++++++++++++++++++++++
contrib/completion/git-completion.zsh | 10 ++++++++++
2 files changed, 40 insertions(+)
@@ -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()+{+localpfx="${3-}"cur_="${4-$cur}"sfx="${5- }"sfx2="${6- }"i=0+localIFS=$' \t\n'++forxin$1;do+if[["$x"=="$cur_"*]];then+COMPREPLY[i++]="$pfx$x$sfx"+fi+done+forxin$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:
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 <redacted>
---
contrib/completion/git-completion.bash | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -30,10 +30,10 @@ if [ -z "$script" ]; thenlocal-alocationslocalelocations=(+$(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)forein$locations;dotest-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