zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/3] _git: Improve reflog completion.
@ 2016-03-18 21:21 Daniel Shahaf
  2016-03-18 21:21 ` [PATCH 2/3] _git reflog: Complete '@{N}' instead of 'HEAD@{N}' Daniel Shahaf
  2016-03-18 21:21 ` [PATCH 3/3] _git: Invoke reflog completion from the 'complete commit objects' codepath Daniel Shahaf
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Shahaf @ 2016-03-18 21:21 UTC (permalink / raw)
  To: zsh-workers

Currently, only used by «git reflog delete <TAB>».
---
 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 1241058..9eeda58 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5474,10 +5474,10 @@ __git_reflog_entries () {
   local expl
   declare -a reflog_entries
 
-  reflog_entries=(${${${(f)"$(_call_program reflog-entries git reflog 2>/dev/null)"}#* }%%:*})
+  reflog_entries=(${(f)"$(_call_program reflog-entries "git reflog -1000 --pretty='%gD:[%h] %gs'" 2>/dev/null)"})
   __git_command_successful $pipestatus || return 1
 
-  _wanted reflog-entries expl 'reflog entry' _multi_parts @ reflog_entries
+  _describe -Vx -t reflog-entries 'reflog entry' reflog_entries
 }
 
 (( $+functions[__git_ref_sort_keys] )) ||


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

* [PATCH 2/3] _git reflog: Complete '@{N}' instead of 'HEAD@{N}'.
  2016-03-18 21:21 [PATCH 1/3] _git: Improve reflog completion Daniel Shahaf
@ 2016-03-18 21:21 ` Daniel Shahaf
  2016-03-18 21:21 ` [PATCH 3/3] _git: Invoke reflog completion from the 'complete commit objects' codepath Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2016-03-18 21:21 UTC (permalink / raw)
  To: zsh-workers

The «HEAD@{...}» syntax is no longer completed, since it's not easily possible
to support both syntaxes (workers/34768).
---
 Completion/Unix/Command/_git | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 9eeda58..0eb8532 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5475,6 +5475,7 @@ __git_reflog_entries () {
   declare -a reflog_entries
 
   reflog_entries=(${(f)"$(_call_program reflog-entries "git reflog -1000 --pretty='%gD:[%h] %gs'" 2>/dev/null)"})
+  reflog_entries=( ${reflog_entries/HEAD@$'\x7b'/@$'\x7b'} )
   __git_command_successful $pipestatus || return 1
 
   _describe -Vx -t reflog-entries 'reflog entry' reflog_entries


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

* [PATCH 3/3] _git: Invoke reflog completion from the 'complete commit objects' codepath.
  2016-03-18 21:21 [PATCH 1/3] _git: Improve reflog completion Daniel Shahaf
  2016-03-18 21:21 ` [PATCH 2/3] _git reflog: Complete '@{N}' instead of 'HEAD@{N}' Daniel Shahaf
@ 2016-03-18 21:21 ` Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2016-03-18 21:21 UTC (permalink / raw)
  To: zsh-workers

The reflog will only be used if the user has typed as "@" by hand.
---
 Completion/Unix/Command/_git | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 0eb8532..ee45576 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5474,7 +5474,9 @@ __git_reflog_entries () {
   local expl
   declare -a reflog_entries
 
-  reflog_entries=(${(f)"$(_call_program reflog-entries "git reflog -1000 --pretty='%gD:[%h] %gs'" 2>/dev/null)"})
+  # Repeat the %gD on the RHS due to uniquify the matches, to avoid bad
+  # completion list layout.  (Compare workers/34768)
+  reflog_entries=(${(f)"$(_call_program reflog-entries "git reflog -1000 --pretty='%gD:[%h] %gs (%gD)'" 2>/dev/null)"})
   reflog_entries=( ${reflog_entries/HEAD@$'\x7b'/@$'\x7b'} )
   __git_command_successful $pipestatus || return 1
 
@@ -5671,8 +5673,13 @@ __git_commit_objects () {
   local gitdir expl start
   declare -a commits
 
-  # Abort if the argument does not match a commit hash (including empty).
-  [[ "$PREFIX$SUFFIX" == [[:xdigit:]](#c1,40) ]] || return 1
+  if [[ -n $PREFIX[(r)@] ]] || [[ -n $SUFFIX[(r)@] ]]; then
+    # doesn't match a commit hash, but might be a reflog entry
+    __git_reflog_entries; return $?
+  elif ! [[ "$PREFIX$SUFFIX" == [[:xdigit:]](#c1,40) ]]; then
+    # Abort if the argument does not match a commit hash (including empty).
+    return 1
+  fi
 
   # Note: the after-the-colon part must be unique across the entire array;
   # see workers/34768


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

end of thread, other threads:[~2016-03-18 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-18 21:21 [PATCH 1/3] _git: Improve reflog completion Daniel Shahaf
2016-03-18 21:21 ` [PATCH 2/3] _git reflog: Complete '@{N}' instead of 'HEAD@{N}' Daniel Shahaf
2016-03-18 21:21 ` [PATCH 3/3] _git: Invoke reflog completion from the 'complete commit objects' codepath 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).