Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: 3.0.8: git completion update for cherry-pick



Currently completion for cherry-pick displays recent commits from the
current branch.
This patch changes this to show recent commits from all branches except HEAD.

Obszczymucha

diff --git a/_git b/_git
index b8edc10..8b9eb2b 100644
--- a/_git
+++ b/_git
@@ -511,7 +511,7 @@ _git-cherry-pick () {
     '*'{-s,--strategy=}'[use given merge strategy]:merge
strategy:__git_merge_strategies' \
     '*'{-X,--strategy-option=}'[pass merge-strategy-specific option
to merge strategy]' \
     '(-e --edit -x -n --no-commit -s --signoff)--ff[fast forward, if
possible]' \
-    ': :__git_commit_ranges'
+    ': :__git_commit_ranges --all --not HEAD'
 }

 (( $+functions[_git-citool] )) ||
@@ -5602,20 +5602,20 @@ __git_remote_branch_names_noprefix () {

 (( $+functions[__git_commit_objects_prefer_recent] )) ||
 __git_commit_objects_prefer_recent () {
-  __git_recent_commits || __git_commit_objects
+  __git_recent_commits $* || __git_commit_objects
 }

 (( $+functions[__git_commits] )) ||
 __git_commits () {
   # TODO: deal with things that __git_heads and __git_tags has in common (i.e.,
   # if both exists, they need to be completed to heads/x and tags/x.
-  local -a sopts ropt
-  zparseopts -E -a sopts S: r:=ropt R: q
+  local -a sopts ropt recentopts
+  zparseopts -E -a sopts S: r:=ropt R: q -all=recentopts -not+:=recentopts
   sopts+=( $ropt:q )
   _alternative \
     "heads::__git_heads $sopts" \
     "commit-tags::__git_commit_tags $sopts" \
-    'commit-objects::__git_commit_objects_prefer_recent'
+    "commit-objects::__git_commit_objects_prefer_recent $recentopts"
 }

 (( $+functions[__git_heads] )) ||
@@ -5669,14 +5669,16 @@ __git_commit_objects () {

 (( $+functions[__git_recent_commits] )) ||
 __git_recent_commits () {
-  local gitdir expl start
+  local gitdir expl start opts
   declare -a descr tags heads commits
   local i j k ret
   integer distance_from_head

+  zparseopts -D -E -a opts -- -all -not:
+
   # Careful: most %d will expand to the empty string.  Quote properly!
   # NOTE: we could use %D directly, but it's not available in git
1.9.1 at least.
-  commits=("${(f)"$(_call_program commits git --no-pager log -20
--format='%h%n%d%n%s\ \(%cr\)')"}")
+  commits=("${(f)"$(_call_program commits git --no-pager log $opts
-20 --format='%h%n%d%n%s\ \(%cr\)')"}")
   __git_command_successful $pipestatus || return 1

   for i j k in "$commits[@]" ; do



Messages sorted by: Reverse Date, Date, Thread, Author