Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: git completion problems



On 12 Dec, Will Gray wrote:
> I have three remote branches: "origin/master", "origin/production",
> and "origin/production-dev".  When I enter "o", it will complete
> "origin".  If I add "/pr", it will not complete "origin/production".
> However, if I enter "o/pr" it will complete "origin/production".
>
> I'm using Zsh 5.1.1 and have downloaded the latest
> Completion/Unix/_git to first entry in my $path.

Sorry, that this didn't get looked at sooner. It arrived at a time when I
was fairly busy.

I think this is caused by essentially the same set of matches - the
branches - getting added more than once with different matching control
specs. They get added once with "r:|/=* r:|=*", once with no match spec
and there's also a call to _multi_parts for file completion thrown into
the mix. It'd be good to know if the following patch fixes the issue for
you. Given certain matcher style settings, it may not. This just makes
it more consistent.

Oliver


diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 8297d6424..f9e6a76e1 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5629,7 +5629,7 @@ __git_describe_branch () {
 
 (( $+functions[__git_describe_commit] )) ||
 __git_describe_commit () {
-  __git_describe_branch $1 $2 $3 -M 'r:|/=**' "${(@)argv[4,-1]}"
+  __git_describe_branch $1 $2 $3 -M 'r:|/=* r:|=*' "${(@)argv[4,-1]}"
 }
 
 # Completion Wrappers
@@ -6546,7 +6546,7 @@ __git_recent_commits () {
   expl=()
   _wanted commit-tags expl 'commit tag' compadd "$@" -a - tags && ret=0
   expl=()
-  _wanted heads expl 'head' compadd "$@" -a - heads && ret=0
+  _wanted heads expl 'head' compadd -M "r:|/=* r:|=*" "$@" -a - heads && ret=0
   return $ret
 }
 
@@ -6671,7 +6671,7 @@ __git_tags () {
   tags=(${${(f)"$(_call_program tagrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
   __git_command_successful $pipestatus || return 1
 
-  _wanted tags expl tag compadd -M 'r:|/=**' "$@" -a - tags
+  _wanted tags expl tag compadd -M 'r:|/=* r:|=*' "$@" -a - tags
 }
 
 (( $+functions[__git_commit_tags] )) ||
@@ -6694,7 +6694,7 @@ __git_tags_of_type () {
   tags=(${${(M)${(f)"$(_call_program ${(q)type}-tag-refs "git for-each-ref --format='%(*objecttype)%(objecttype) %(refname)' refs/tags 2>/dev/null")"}:#$type(tag|) *}#$type(tag|) refs/tags/})
   __git_command_successful $pipestatus || return 1
 
-  _wanted $type-tags expl "$type tag" compadd -M 'r:|/=**' "$@" -a - tags
+  _wanted $type-tags expl "$type tag" compadd -M 'r:|/=* r:|=*' "$@" -a - tags
 }
 
 # Reference Argument Types
@@ -6717,7 +6717,7 @@ __git_references () {
     _git_refs_cache_pwd=$PWD
   fi
 
-  _wanted references expl 'reference' compadd -M 'r:|/=**' -a - _git_refs_cache
+  _wanted references expl 'reference' compadd -M 'r:|/=* r:|=*' -a - _git_refs_cache
 }
 
 # ### currently unused; are some callers of __git_references supposed to call this function?
@@ -6731,7 +6731,7 @@ __git_local_references () {
     _git_local_refs_cache_pwd=$PWD
   fi
 
-  _wanted references expl 'reference' compadd -M 'r:|/=**' -a - _git_local_refs_cache
+  _wanted references expl 'reference' compadd -M 'r:|/=* r:|=*' -a - _git_local_refs_cache
 }
 
 (( $+functions[__git_remote_references] )) ||



Messages sorted by: Reverse Date, Date, Thread, Author