Improvements to Bash completion (#1210)

* Sort Bash completion functions

* feat: add Bash completion for `git rename-branch`

* feat: add Bash completion for `git rename-remote`

* feat: add Bash completion for `git rename-tag`

* fix: use default completion for `git rename-file`

* Refactor rename completion functions common logic
This commit is contained in:
Daniele Paolella 2025-08-29 12:29:31 +02:00 committed by GitHub
parent 14586c7da0
commit cf6d40d446
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,22 @@
# shellcheck shell=bash
# bash completion support for git-extras.
_git_authors(){
__gitcomp "-l --list --no-email"
}
_git_browse(){
__git_complete_remote_or_refspec
}
_git_browse_ci(){
__git_complete_remote_or_refspec
}
_git_brv(){
__gitcomp "-r --reverse"
}
_git_changelog(){
local s_opts=( '-a' '-l' '-t' '-f' '-s' '-n' '-p' '-x' '-h' '?' )
local l_opts=(
@ -22,14 +38,6 @@ _git_changelog(){
__gitcomp "$merged_opts_str"
}
_git_authors(){
__gitcomp "-l --list --no-email"
}
_git_brv(){
__gitcomp "-r --reverse"
}
_git_coauthor(){
local oldIfs=$IFS
IFS=$'\n'
@ -136,6 +144,10 @@ _git_ignore(){
esac
}
_git_info(){
__gitcomp "--color -c --no-config"
}
_git_missing(){
# Suggest all known refs
__gitcomp "$(git for-each-ref --format='%(refname:short)')"
@ -158,38 +170,40 @@ _git_reauthor(){
__gitcomp "${comp}"
}
_git_scp(){
__git_complete_remote_or_refspec
__git_extras_rename(){
if ((COMP_CWORD == 2 || COMP_CWORD == 3)); then
__gitcomp "$1"
fi
}
_git_stamp(){
__gitcomp '--replace -r'
_git_rename_branch(){
__git_extras_rename "$(__git_heads)"
}
_git_rename_remote(){
__git_extras_rename "$(__git_remotes)"
}
_git_rename_tag(){
__git_extras_rename "$(__git_tags)"
}
_git_rscp(){
__git_complete_remote_or_refspec
}
_git_scp(){
__git_complete_remote_or_refspec
}
_git_squash(){
__gitcomp "$(__git_heads)"
}
_git_stamp(){
__gitcomp '--replace -r'
}
_git_undo(){
__gitcomp "--hard --soft -h -s"
}
_git_info(){
__gitcomp "--color -c --no-config"
}
_git_browse(){
__git_complete_remote_or_refspec
}
_git_browse_ci(){
__git_complete_remote_or_refspec
}
_git_rename_file() {
__gitcomp "-h --help"
}