zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] _git-checkout: Reorder default completions.
Date: Sun, 5 Feb 2017 09:11:05 +0000	[thread overview]
Message-ID: <20170205091105.GA20317@fujitsu.shahaf.local2> (raw)

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

A quick series to change the order of alternatives in 'git checkout
<TAB>'.  I realize it's somewhat of a bikeshed, but on the other hand,
I'd like to have good defaults.

Cheers,

Daniel

[-- Attachment #2: 0001-_git-checkout-No-functional-change.patch --]
[-- Type: text/x-diff, Size: 2092 bytes --]

>From c7a91ce338a3a0c2245bc79e892f10e3fc28cc1a Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Thu, 28 Jul 2016 12:25:52 +0000
Subject: [PATCH 1/2] _git-checkout: No functional change.

This makes the next diff smaller.
---
 Completion/Unix/Command/_git | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index b5b3e79..8b78b57 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -473,28 +473,24 @@ _git-checkout () {
       [[ $line[CURRENT] = -* ]] && return
       if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then
         # TODO: Allow A...B
-        local branch_arg='' \
+        local \
               remote_branch_noprefix_arg='remote-branch-names-noprefix::__git_remote_branch_names_noprefix' \
               tree_ish_arg='tree-ishs::__git_tree_ishs' \
               file_arg='modified-files::__git_modified_files'
 
         if [[ -n ${opt_args[(I)-b|-B|--orphan|--detach]} ]]; then
-          remote_branch_noprefix_arg=
-          file_arg=
+          _alternative $tree_ish_arg && ret=0
         elif [[ -n $opt_args[(I)--track] ]]; then
-          branch_arg='remote-branches::__git_remote_branch_names'
-          remote_branch_noprefix_arg=
-          tree_ish_arg=
-          file_arg=
+          _alternative remote-branches::__git_remote_branch_names && ret=0
         elif [[ -n ${opt_args[(I)--ours|--theirs|-m|--conflict|--patch]} ]]; then
-          remote_branch_noprefix_arg=
+          _alternative $tree_ish_arg $file_arg && ret=0
+        else
+          _alternative \
+            $remote_branch_noprefix_arg \
+            $tree_ish_arg \
+            $file_arg && ret=0
         fi
 
-        _alternative \
-          $branch_arg \
-          $remote_branch_noprefix_arg \
-          $tree_ish_arg \
-          $file_arg && ret=0
       elif [[ -n ${opt_args[(I)-b|-B|-t|--track|--orphan|--detach]} ]]; then
         _nothing
       elif [[ -n $line[1] ]] && __git_is_treeish $line[1]; then

[-- Attachment #3: 0002-_git-checkout-Reorder-default-completions.patch --]
[-- Type: text/x-diff, Size: 1277 bytes --]

>From da2fffa6076bf4b4ff7d6dc22c1b8ec2cea8a045 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Thu, 28 Jul 2016 12:37:14 +0000
Subject: [PATCH 2/2] _git-checkout: Reorder default completions.

The unprefixed name of a remote branch is used to create a new local
remote-tracking branch; that is presumed to be a rarer operation than
either switching among local branches or reverting to the index version
of a modified file.

Between the remaining two, put modified files before tree-ishes because
there are generally few of the former and many of the latter.
---
 Completion/Unix/Command/_git | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 8b78b57..b16d2bc 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -486,9 +486,10 @@ _git-checkout () {
           _alternative $tree_ish_arg $file_arg && ret=0
         else
           _alternative \
-            $remote_branch_noprefix_arg \
+            $file_arg \
             $tree_ish_arg \
-            $file_arg && ret=0
+            $remote_branch_noprefix_arg \
+            && ret=0
         fi
 
       elif [[ -n ${opt_args[(I)-b|-B|-t|--track|--orphan|--detach]} ]]; then

                 reply	other threads:[~2017-02-05  9:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170205091105.GA20317@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).