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

[PATCH 2/2] _git-checkout: When completing local heads, prefer recently-checked-out ones. (after 38592)



---
This changes the completion of local branch names at «git checkout <TAB>»
by finally hooking up the code written in 38592 by default.

In my experience, the cold cache behaviour was sometimes a bit slow.  If
others see this too then perhaps the 'depth' constant down in
__git_recent_branches should be reduced?

Cheers,

Daniel

 Completion/Unix/Command/_git | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 73daedc..85aac92 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -476,7 +476,7 @@ _git-checkout () {
         # TODO: Allow A...B
         local \
               remote_branch_noprefix_arg='remote-branch-names-noprefix::__git_remote_branch_names_noprefix' \
-              tree_ish_arg='tree-ishs::__git_tree_ishs' \
+              tree_ish_arg='tree-ishs::__git_commits_prefer_recent' \
               file_arg='modified-files::__git_modified_files'
 
         if [[ -n ${opt_args[(I)-b|-B|--orphan|--detach]} ]]; then
@@ -6169,6 +6169,10 @@ __git_recent_branches() {
   _describe -V -t recent-branches "recent branches" branches_colon_descriptions
 }
 
+(( $+functions[__git_commits_prefer_recent] )) ||
+__git_commits_prefer_recent () {
+  _alternative 'recent-branches::__git_recent_branches' 'commits::__git_commits'
+}
 
 (( $+functions[__git_commits] )) ||
 __git_commits () {



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