mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
Add git completions for git push REMOTE :BRANCH
`git push REMOTE :BRANCH` deletes remote branch BRANCH from remote REMOTE. Should only kick in when the pattern matches, hopefully didn't break anything else!
This commit is contained in:
parent
3b3047c3f6
commit
0aa4c4a483
1 changed files with 8 additions and 0 deletions
|
@ -240,6 +240,12 @@ function __fish_git_branch_for_remote
|
||||||
__fish_git_branches | string match -- "$remote/*" | string replace -- "$remote/" ''
|
__fish_git_branches | string match -- "$remote/*" | string replace -- "$remote/" ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function __fish_git_branch_for_remote_delete
|
||||||
|
for r in (__fish_git_branch_for_remote)
|
||||||
|
echo :$r
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Return 0 if the current token is a possible commit-hash with at least 3 characters
|
# Return 0 if the current token is a possible commit-hash with at least 3 characters
|
||||||
function __fish_git_possible_commithash
|
function __fish_git_possible_commithash
|
||||||
set -q argv[1]
|
set -q argv[1]
|
||||||
|
@ -743,6 +749,8 @@ complete -f -c git -n '__fish_git_using_command push; and not __fish_git_branch_
|
||||||
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote' -a '(__fish_git_branches)' -d 'Branch'
|
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote' -a '(__fish_git_branches)' -d 'Branch'
|
||||||
# The "refspec" here is an optional "+" to signify a force-push
|
# The "refspec" here is an optional "+" to signify a force-push
|
||||||
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "+*" -- (commandline -ct)' -a '+(__fish_git_branches)' -d 'Force-push branch'
|
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "+*" -- (commandline -ct)' -a '+(__fish_git_branches)' -d 'Force-push branch'
|
||||||
|
# git push REMOTE :BRANCH deletes BRANCH on remote REMOTE
|
||||||
|
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q ":" -- (commandline -ct)' -a '(__fish_git_branch_for_remote_delete)' -d 'Delete remote branch'
|
||||||
# then src:dest (where both src and dest are git objects, so we want to complete branches)
|
# then src:dest (where both src and dest are git objects, so we want to complete branches)
|
||||||
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "+*:*" -- (commandline -ct)' -a '+(__fish_git_branches):(__fish_git_branch_for_remote)' -d 'Force-push local branch to remote branch'
|
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "+*:*" -- (commandline -ct)' -a '+(__fish_git_branches):(__fish_git_branch_for_remote)' -d 'Force-push local branch to remote branch'
|
||||||
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "*:*" -- (commandline -ct)' -a '(__fish_git_branches):(__fish_git_branch_for_remote)' -d 'Push local branch to remote branch'
|
complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "*:*" -- (commandline -ct)' -a '(__fish_git_branches):(__fish_git_branch_for_remote)' -d 'Push local branch to remote branch'
|
||||||
|
|
Loading…
Reference in a new issue