zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] completion: git: split __git_heads into local and remote
@ 2015-05-08 13:41 Daniel Hahler
  2015-05-10 16:13 ` Daniel Shahaf
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Hahler @ 2015-05-08 13:41 UTC (permalink / raw)
  To: zsh-workers

From: Daniel Hahler <git@thequod.de>

It is useful to have this distinction visually.

This also uses `--format=%(refname:short)` directly with `git
for-each-ref`.
---
 Completion/Unix/Command/_git | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 979e3e7..c01333b 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5614,10 +5614,16 @@ __git_commits () {
 
 (( $+functions[__git_heads] )) ||
 __git_heads () {
+  __git_heads_local
+  __git_heads_remote
+}
+
+(( $+functions[__git_heads_local] )) ||
+__git_heads_local () {
   local gitdir expl start
   declare -a heads
 
-  heads=(${${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname)"' refs/heads refs/remotes 2>/dev/null)"}#refs/(heads|remotes)/})
+  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
@@ -5626,7 +5632,17 @@ __git_heads () {
     [[ -f $gitdir/refs/stash ]] && heads+=stash
   fi
 
-  _wanted heads expl head compadd "$@" -a - heads
+  _wanted heads-local expl "local head" compadd "$@" -a - heads
+}
+
+(( $+functions[__git_heads_remote] )) ||
+__git_heads_remote () {
+  local gitdir expl start
+  declare -a heads
+
+  heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)" refs/remotes' 2>/dev/null)"})
+
+  _wanted heads-remote expl "remote head" compadd "$@" -a - heads
 }
 
 (( $+functions[__git_commit_objects] )) ||
-- 
2.4.0.dirty


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

* Re: [PATCH] completion: git: split __git_heads into local and remote
  2015-05-08 13:41 [PATCH] completion: git: split __git_heads into local and remote Daniel Hahler
@ 2015-05-10 16:13 ` Daniel Shahaf
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2015-05-10 16:13 UTC (permalink / raw)
  To: Daniel Hahler; +Cc: zsh-workers

Daniel Hahler wrote on Fri, May 08, 2015 at 15:41:01 +0200:
> From: Daniel Hahler <git@thequod.de>
> 
> It is useful to have this distinction visually.

Thanks, I think this is a good change.

I have one concern, however.  The 'heads' tag is split into two new tags:

> -  _wanted heads expl head compadd "$@" -a - heads
> +  _wanted heads-local expl "local head" compadd "$@" -a - heads
> +  _wanted heads-remote expl "remote head" compadd "$@" -a - heads

That's a backwards-incompatible change.  (If people have "heads" in
their tag-order styles, their setup will be silently broken.)  I'm not
sure how this should be handled.

I spoke with Daniel on IRC and we both preferred to keep the change and
mention it in NEWS as an incompatibility.  (I went ahead and drafted
this; patch enclosed.)

Personally, I'm a little torn on this: I keep thinking there might be
a way to split the 'heads' tag without breaking existing setups that
refer to it.  So far, I haven't found any.  I'd still vote for merging
the patch, though, backwards incompatibility notwithstanding.  (Since
the breakage — heads not being offered as completions — would be easily
noticeable by the user, harmless, and would not affect the default
setup.)

Cheers,

Daniel

P.S. Peter — are you waiting on this for 5.0.8?  Normally I'd assume we
can take our time getting the patch right, but I wouldn't want to be the
late-boarding passenger whom everyone waits for.

---

[[[
diff --git a/README b/README
index 142daad..73190a5 100644
--- a/README
+++ b/README
@@ -117,6 +117,12 @@ New behaviour:
 0.5
 
 
+4) The _git completion used to offer both local and remote heads under the
+tag 'heads'.  The tag has now been split into 'heads-local' and
+'heads-remote' in all contexts that existed in 5.0.7.  The --fixup/--squash
+context still uses the tag 'heads' (but this may change in a future release).
+
+
 Incompatibilities between 5.0.2 and 5.0.5
 -----------------------------------------
 
]]]

> This also uses `--format=%(refname:short)` directly with `git
> for-each-ref`.


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

end of thread, other threads:[~2015-05-10 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08 13:41 [PATCH] completion: git: split __git_heads into local and remote Daniel Hahler
2015-05-10 16:13 ` 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).