zsh-users
 help / color / mirror / code / Atom feed
* git completion problems
@ 2017-12-12 17:00 Will Gray
  2018-06-13 16:16 ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: Will Gray @ 2017-12-12 17:00 UTC (permalink / raw)
  To: zsh-users

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.

-- 
Will Gray
Nashville, TN


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git completion problems
  2017-12-12 17:00 git completion problems Will Gray
@ 2018-06-13 16:16 ` Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2018-06-13 16:16 UTC (permalink / raw)
  To: Will Gray; +Cc: zsh-users

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] )) ||


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-13 16:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12 17:00 git completion problems Will Gray
2018-06-13 16:16 ` Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).