summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-03-18 21:21:45 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-03-21 16:12:15 +0000
commit9f7040471473f5dedf0ae71a1973bc2606624aea (patch)
tree3bbd02acfb5c641ad3e6c136f769f542846e3d14 /Completion
parentce4c9eafc491aad1213a1cc8e3c6e07057a01e4b (diff)
downloadzsh-9f7040471473f5dedf0ae71a1973bc2606624aea.tar.gz
zsh-9f7040471473f5dedf0ae71a1973bc2606624aea.tar.xz
zsh-9f7040471473f5dedf0ae71a1973bc2606624aea.zip
38182: _git: Invoke reflog completion from the 'complete commit objects' codepath.
The reflog will only be used if the user has typed as "@" by hand.
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_git13
1 files changed, 10 insertions, 3 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 0eb8532e2..ee455764f 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