Commit 97aeced1 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Improved branch searching in git-supertree completion

parent c9f42e92
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -44,14 +44,23 @@ _git-supertree()
					;;

				(convert)
					declare -a refs=( $(git for-each-ref \
						--format='%(refname:short)' \
						refs/heads \
					) )
					_arguments \
						"--master[Override the value of the base HEAD symbolic ref]:ref:($(__git_supertree_list_branches))" \
						"--master[Override the value of the base HEAD symbolic ref]:ref:(${refs[*]})" \
						'::path:_directories' \
					;;

				(add)
					declare -a refs=( $(git for-each-ref \
						--format='%(refname:short)' \
						refs/heads \
						refs/remotes \
					) )
					_arguments \
						"--from[Override the value of the base HEAD symbolic ref]:ref:($(__git_supertree_list_branches))" \
						"--from[Use a branch other than the value of the base HEAD symbolic ref]:ref:(${refs[*]})" \
						':BRANCH:__git_supertree_branch_spec' \
					;;

@@ -65,15 +74,11 @@ _git-supertree()
	esac
}


__git_supertree_list_branches()
{
	git branch -l | grep -v '*'
}

__git_supertree_branch_spec()
{
	_sep_parts "( $(__git_supertree_list_branches) )" : '*'
	declare -a refs=( $(git for-each-ref --format='%(refname:short)' refs/heads) )
	refs+=( $(git for-each-ref --format='%(refname:strip=3)' refs/remotes) )
	_sep_parts "(${refs[*]})" : '*'
}

zstyle ':completion:*:*:git:*' user-commands supertree:'manage a collection of worktrees'