From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12652 invoked by alias); 22 Sep 2013 10:49:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31748 Received: (qmail 19022 invoked from network); 22 Sep 2013 10:48:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.217.172 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=uwcdyy05Qk5r2liJPRe4Em9q6MINMBQgLXt/3clhEVg=; b=juf7hHCpwMkksChFT5/ksZAO6zlA4Q61DAtEitfpcpE31TZDqyaWJ/p2nL0HiHeoR9 xKxGZWHNjKobYBOHIqvwZgMDYVPahYoSo/XKzDA7WuFaXt7ODONqhq3v5UYvGBah7y4R bGHUKmGd39La/RovkMwyus2OGB7beqmAAx85Kg+0kgqDlTh4PhjVR+63Mo736AeTHelR shtp/zCIdRayhBWpvONUbCv4I5vwIXmGF3v2180vjaHeFslHBNfEXR0jX3HOeSnr3HeC +fE2oDhqw8489blLjKy1eodPqbJq8O8SbbF31bb7mEvesRjXXLEhhyXlkFemkJdsacaf SnfA== X-Received: by 10.152.29.103 with SMTP id j7mr14617680lah.7.1379846930866; Sun, 22 Sep 2013 03:48:50 -0700 (PDT) From: =?UTF-8?q?=C3=98ystein=20Walle?= To: zsh-workers@zsh.org Cc: m0viefreak Subject: [PATCH v2 09/14] _git: support completing remote branches without / prefix Date: Sun, 22 Sep 2013 12:48:23 +0200 Message-Id: <026c333dd802bc8ed890acfdf008d5de8c97eb23.1379846744.git.oystwa@gmail.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: References: In-Reply-To: References: From: m0viefreak this is used in git 1.8's git checkout as a shorthand for git checkout -b --track / in case exists on exactly one remote and is not a local branch --- Completion/Unix/Command/_git | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 0d0cb02..9d07453 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -440,22 +440,27 @@ _git-checkout () { if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then # TODO: Allow A...B local branch_arg='branches::__git_revisions' \ + remote_branch_noprefix_arg='remote branches::__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]} ]]; then + remote_branch_noprefix_arg= tree_ish_arg= file_arg= elif [[ -n $opt_args[(I)--track] ]]; then branch_arg='remote-branches::__git_remote_branch_names' + remote_branch_noprefix_arg= tree_ish_arg= file_arg= elif [[ -n ${opt_args[(I)--ours|--theirs|-m|--conflict|--patch]} ]]; then branch_arg= + remote_branch_noprefix_arg= 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]} ]]; then @@ -5371,6 +5376,17 @@ __git_remote_branch_names () { _wanted remote-branch-names expl 'remote branch name' compadd $* - $branch_names } +(( $+functions[__git_remote_branch_names_noprefix] )) || +__git_remote_branch_names_noprefix () { + local expl + declare -a heads + + branch_names=(${${${(f)"$(_call_program remote-branch-refs-noprefix git for-each-ref --format='"%(refname)"' refs/remotes 2>/dev/null)"}##*/}:#HEAD}) + __git_command_successful $pipestatus || return 1 + + _wanted remote-branch-names-noprefix expl 'remote branch name' compadd $* - $branch_names +} + (( $+functions[__git_commits] )) || __git_commits () { # TODO: deal with things that __git_heads and __git_tags has in common (i.e., -- 1.8.2.2