Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 09/16] _git: support completing remote branches without <remote>/ prefix
- X-seq: zsh-workers 31599
- From: Øystein Walle <oystwa@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 09/16] _git: support completing remote branches without <remote>/ prefix
- Date: Sun, 28 Jul 2013 18:22:06 +0200
- Cc: m0viefreak.cm@xxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=t3iMtA6UkYAy5JKtbztF6YlTSCLvQMn3Rg5FvJ42fLk=; b=B/UOgd3sWHyBwcCOE4PJMmLLZ5fO0dB0pc6bo0IoRNV0s9g1H82LQv1oJdNqUyU/x4 yXvt4pkImaBtTS0zKPmS3uMbEiV9wD8dFgtc0JTKKhKoxPazHz4leZSgGZJV26yQWgIb ldxUnx3WbEC2lWW5Gmk6/tfdqHgdIuIz1AxAMYFbfDItXtu6VoKFK1acTMz5Pyk07cQO a1k73l8Uv3a7P/8JtJ78UKdRLq/Xc/GTOq3mjeb10UxZRGMXjJSpToFSEoKVpjYfFtmf DQyBKT+kjPg+x5rWMtE+5EZyAqmvLujnGEhW8C9/8iOlHaP2cTnyjs39OXvswetJj4XX LAeQ==
- In-reply-to: <cover.1375006129.git.oystwa@gmail.com>
- In-reply-to: <cover.1375006129.git.oystwa@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <cover.1375006129.git.oystwa@gmail.com>
- References: <cover.1375006129.git.oystwa@gmail.com>
From: m0viefreak <m0viefreak.cm@xxxxxxxxxxxxxx>
this is used in git 1.8's
git checkout <branch>
as a shorthand for
git checkout -b <branch> --track <remote>/<branch>
in case <branch> 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 2c74f2c..87edae9 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
@@ -5372,6 +5377,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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author