mirror of
https://github.com/tj/git-extras.git
synced 2026-09-15 09:56:19 -04:00
feat: delete-branch multiple unique branch names completions (#1221)
This commit is contained in:
parent
f5c48e4842
commit
6f4cf0c1bb
|
|
@ -1,6 +1,13 @@
|
|||
# shellcheck shell=bash
|
||||
# bash completion support for git-extras.
|
||||
|
||||
__gitex_heads_unique() {
|
||||
local branch specified=("${COMP_WORDS[@]:2}")
|
||||
for branch in $(__git_heads); do
|
||||
[[ " ${specified[*]} " == *" $branch "* ]] || printf '%s\n' "$branch"
|
||||
done
|
||||
}
|
||||
|
||||
_git_authors(){
|
||||
__gitcomp "-l --list --no-email"
|
||||
}
|
||||
|
|
@ -84,7 +91,7 @@ __git_cp(){
|
|||
}
|
||||
|
||||
_git_delete_branch(){
|
||||
__gitcomp "$(__git_heads)"
|
||||
__gitcomp "$(__gitex_heads_unique)"
|
||||
}
|
||||
|
||||
_git_delete_squashed_branches(){
|
||||
|
|
|
|||
|
|
@ -72,6 +72,15 @@ __gitex_branch_names() {
|
|||
_wanted branch-names expl branch-name compadd $* - $branch_names
|
||||
}
|
||||
|
||||
__gitex_branch_names_unique() {
|
||||
local expl
|
||||
declare -a branch_names already_specified
|
||||
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
|
||||
__gitex_command_successful || return
|
||||
already_specified=(${words[2,-1]})
|
||||
_wanted branch-names expl branch-name compadd -F already_specified $* - $branch_names
|
||||
}
|
||||
|
||||
__gitex_specific_branch_names() {
|
||||
local expl
|
||||
declare -a branch_names
|
||||
|
|
@ -196,8 +205,7 @@ _git-create-branch() {
|
|||
}
|
||||
|
||||
_git-delete-branch() {
|
||||
_arguments \
|
||||
':branch-name:__gitex_branch_names'
|
||||
__gitex_branch_names_unique
|
||||
}
|
||||
|
||||
_git-delete-squashed-branches() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue