feat: delete-branch multiple unique branch names completions (#1221)

This commit is contained in:
johnpyp 2025-12-18 15:40:24 -05:00 committed by GitHub
parent f5c48e4842
commit 6f4cf0c1bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View file

@ -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(){

View file

@ -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() {