zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 0/5] Completion: git refspecs
@ 2016-04-30  0:48 Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 1/5] _git-bundle: Complete required file argument to 'git bundle' correctly Daniel Shahaf
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Daniel Shahaf @ 2016-04-30  0:48 UTC (permalink / raw)
  To: zsh-workers

The first three patches are trivial fixes; however, I'd appreciate a second
pair of eyes over the fourth and fifth.

Eventually I'd like «git fetch ${remote} <TAB>» to complete branch names from
that remote (via for-each-ref and/or ls-remote).

Cheers,

Daniel


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

* [PATCH 1/5] _git-bundle: Complete required file argument to 'git bundle' correctly.
  2016-04-30  0:48 [PATCH 0/5] Completion: git refspecs Daniel Shahaf
@ 2016-04-30  0:48 ` Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 2/5] _git: Offer alternatives properly Daniel Shahaf
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2016-04-30  0:48 UTC (permalink / raw)
  To: zsh-workers

---
 Completion/Unix/Command/_git | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 7ce5b2b..a925efb 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -388,6 +388,7 @@ _git-bundle () {
           ;;
         (list-heads|unbundle)
           _arguments \
+            ':bundle:_files' \
             '*: :__git_ref_specs' && ret=0
           ;;
       esac


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

* [PATCH 2/5] _git: Offer alternatives properly.
  2016-04-30  0:48 [PATCH 0/5] Completion: git refspecs Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 1/5] _git-bundle: Complete required file argument to 'git bundle' correctly Daniel Shahaf
@ 2016-04-30  0:48 ` Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 3/5] _git: Fix an apparent typo in __git_heads() Daniel Shahaf
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2016-04-30  0:48 UTC (permalink / raw)
  To: zsh-workers

---
 Completion/Unix/Command/_git | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index a925efb..c41b352 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5638,8 +5638,7 @@ __git_commits () {
 
 (( $+functions[__git_heads] )) ||
 __git_heads () {
-  __git_heads_local "$@"
-  __git_heads_remote "$@"
+  _alternative 'heads-local::__git_heads_local' 'heads-remote::__git_heads_remote'
 }
 
 (( $+functions[__git_heads_local] )) ||


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

* [PATCH 3/5] _git: Fix an apparent typo in __git_heads().
  2016-04-30  0:48 [PATCH 0/5] Completion: git refspecs Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 1/5] _git-bundle: Complete required file argument to 'git bundle' correctly Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 2/5] _git: Offer alternatives properly Daniel Shahaf
@ 2016-04-30  0:48 ` Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 4/5] _git: Bifurcate __git_ref_specs Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 5/5] _git: Complete fetchy refspecs correctly Daniel Shahaf
  4 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2016-04-30  0:48 UTC (permalink / raw)
  To: zsh-workers

I couldn't reproduce different behaviour with and without this patch, although
the called command's output differs.
---
 Completion/Unix/Command/_git | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index c41b352..46e62e0 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5646,7 +5646,7 @@ __git_heads_local () {
   local gitdir
   declare -a heads
 
-  heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)" refs/heads' 2>/dev/null)"})
+  heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)"' refs/heads 2>/dev/null)"})
   gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
   if __git_command_successful $pipestatus; then
     for f in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
@@ -5663,7 +5663,7 @@ __git_heads_local () {
 __git_heads_remote () {
   declare -a heads
 
-  heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)" refs/remotes' 2>/dev/null)"})
+  heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)"' refs/remotes 2>/dev/null)"})
 
   __git_describe_commit heads heads-remote "remote head" "$@"
 }


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

* [PATCH 4/5] _git: Bifurcate __git_ref_specs.
  2016-04-30  0:48 [PATCH 0/5] Completion: git refspecs Daniel Shahaf
                   ` (2 preceding siblings ...)
  2016-04-30  0:48 ` [PATCH 3/5] _git: Fix an apparent typo in __git_heads() Daniel Shahaf
@ 2016-04-30  0:48 ` Daniel Shahaf
  2016-04-30  0:48 ` [PATCH 5/5] _git: Complete fetchy refspecs correctly Daniel Shahaf
  4 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2016-04-30  0:48 UTC (permalink / raw)
  To: zsh-workers

No functional change, except for completion of 'git bundle' and 'git config
branch.*.merge'; this is a required groundwork for future patches.
---
 Completion/Unix/Command/_git | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 46e62e0..f0cc185 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -389,7 +389,7 @@ _git-bundle () {
         (list-heads|unbundle)
           _arguments \
             ':bundle:_files' \
-            '*: :__git_ref_specs' && ret=0
+            '*: :__git_references' && ret=0
           ;;
       esac
       ;;
@@ -826,7 +826,7 @@ _git-fetch () {
   case $state in
     (repository-or-group-or-refspec)
       if (( CURRENT > 1 )) && [[ -z ${opt_args[(I)--multiple]} ]]; then
-        __git_ref_specs && ret=0
+        __git_ref_specs_fetchy && ret=0
       else
         _alternative \
           'remotes::__git_remotes' \
@@ -1262,7 +1262,7 @@ _git-pull () {
     '(-r --rebase            )--no-rebase[do not perform a rebase after fetching]' \
     $fetch_options \
     ': :__git_any_repositories' \
-    '*: :__git_ref_specs'
+    '*: :__git_ref_specs_fetchy'
 }
 
 (( $+functions[_git-push] )) ||
@@ -1296,7 +1296,7 @@ _git-push () {
     '--recurse-submodules=[submodule handling]:submodule handling:((check\:"refuse pushing of supermodule if submodule commit cannot be found on the remote"
                                                                     on-demand\:"push all changed submodules"))' \
     ': :__git_any_repositories' \
-    '*: :__git_ref_specs' && ret=0
+    '*: :__git_ref_specs_pushy' && ret=0
 
   case $state in
     (lease)
@@ -1936,7 +1936,7 @@ _git-config () {
     branch.autosetupmerge:'set up new branches for git pull::->bool:true'
     branch.autosetuprebase:'rebase new branches of merge for autosetupmerge::->branch.autosetuprebase:never'
     'branch.*.remote:what remote git fetch and git push should fetch form/push to::__git_remotes'
-    'branch.*.merge:default refspec to be marked for merging::__git_ref_specs'
+    'branch.*.merge:default refspec to be marked for merging::__git_remote_references'
     'branch.*.mergeoptions:default options for merging::->branch.mergeoptions'
     'branch.*.pushremote:what remote git push should push to::__git_remotes'
     'branch.*.rebase:rebase on top of fetched branch::->bool:false'
@@ -2236,8 +2236,8 @@ _git-config () {
     'remote.*.pushurl:push URL of a remote repository::__git_any_repositories'
     'remote.*.proxy:URL of proxy to use for a remote repository::_urls'
     'remote.*.prune:remove any remote tracking branches that no longer exist remotely::->bool:false'
-    'remote.*.fetch:default set of refspecs for git fetch::__git_ref_specs'
-    'remote.*.push:default set of refspecs for git push::__git_ref_specs'
+    'remote.*.fetch:default set of refspecs for git fetch::__git_ref_specs_fetchy'
+    'remote.*.push:default set of refspecs for git push::__git_ref_specs_pushy'
     'remote.*.mirror:push with --mirror::->bool:false'
     'remote.*.skipDefaultUpdate:skip this remote by default::->bool:false'
     'remote.*.skipFetchAll:skip this remote by default::->bool:false'
@@ -2330,7 +2330,7 @@ _git-config () {
     'svn-remote.*.rewriteUUID:remap URLs and UUIDs for mirrors manually::->bool:false'
     'svn-remote.*.ignore-paths:regular expression of paths to not check out:regular expression:->string'
     'svn-remote.*.url:URL to connect to::_urls'
-    'svn-remote.*.fetch:fetch specification::__git_ref_specs'
+    'svn-remote.*.fetch:fetch specification::__git_ref_specs_fetchy' # ### undocumented
     'svn-remote.*.pushurl:URL to push to::_urls'
     'svn-remote.*.branches:branch mappings:branch mapping:->string'
     'svn-remote.*.tags:tag mappings:tag mapping:->string'
@@ -5349,8 +5349,8 @@ __git_remotes () {
   _wanted remotes expl remote compadd "$@" -a - remotes
 }
 
-(( $+functions[__git_ref_specs] )) ||
-__git_ref_specs () {
+(( $+functions[__git_ref_specs_pushy] )) ||
+__git_ref_specs_pushy () {
   # TODO: This needs to deal with a lot more types of things.
   if compset -P '*:'; then
     # TODO: have the caller supply the correct remote name, restrict to refs/remotes/${that_remote}/* only
@@ -5367,6 +5367,20 @@ __git_ref_specs () {
   fi
 }
 
+(( $+functions[__git_ref_specs_fetchy] )) ||
+__git_ref_specs_fetchy () {
+  # TODO: this is wrong
+  __git_ref_specs_pushy "$@"
+}
+
+(( $+functions[__git_ref_specs] )) ||
+__git_ref_specs () {
+  # Backwards compatibility: define this function to support user dotfiles that
+  # define custom _git-${subcommand} completions in terms of this function.
+  # ### We may want to warn here "use _pushy() or _fetchy()".
+  __git_ref_specs_pushy "$@"
+}
+
 (( $+functions[__git_color_whens] )) ||
 __git_color_whens () {
   local -a whens


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

* [PATCH 5/5] _git: Complete fetchy refspecs correctly.
  2016-04-30  0:48 [PATCH 0/5] Completion: git refspecs Daniel Shahaf
                   ` (3 preceding siblings ...)
  2016-04-30  0:48 ` [PATCH 4/5] _git: Bifurcate __git_ref_specs Daniel Shahaf
@ 2016-04-30  0:48 ` Daniel Shahaf
  4 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2016-04-30  0:48 UTC (permalink / raw)
  To: zsh-workers

---
 Completion/Unix/Command/_git | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index f0cc185..90789de 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5369,8 +5369,19 @@ __git_ref_specs_pushy () {
 
 (( $+functions[__git_ref_specs_fetchy] )) ||
 __git_ref_specs_fetchy () {
-  # TODO: this is wrong
-  __git_ref_specs_pushy "$@"
+  # TODO: This needs to deal with a lot more types of things.
+  if compset -P '*:'; then
+    __git_heads_local
+  else
+    compset -P '+'
+    if compset -S ':*'; then
+      # TODO: have the caller supply the correct remote name, restrict to refs/remotes/${that_remote}/* only
+      __git_remote_branch_names_noprefix
+    else
+      # TODO: have the caller supply the correct remote name, restrict to refs/remotes/${that_remote}/* only
+      __git_remote_branch_names_noprefix -qS :
+    fi
+  fi
 }
 
 (( $+functions[__git_ref_specs] )) ||


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

end of thread, other threads:[~2016-04-30  0:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-30  0:48 [PATCH 0/5] Completion: git refspecs Daniel Shahaf
2016-04-30  0:48 ` [PATCH 1/5] _git-bundle: Complete required file argument to 'git bundle' correctly Daniel Shahaf
2016-04-30  0:48 ` [PATCH 2/5] _git: Offer alternatives properly Daniel Shahaf
2016-04-30  0:48 ` [PATCH 3/5] _git: Fix an apparent typo in __git_heads() Daniel Shahaf
2016-04-30  0:48 ` [PATCH 4/5] _git: Bifurcate __git_ref_specs Daniel Shahaf
2016-04-30  0:48 ` [PATCH 5/5] _git: Complete fetchy refspecs correctly Daniel Shahaf

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