From 43c87e13c913d48b49a3b8d30410dc008bf9a33c Mon Sep 17 00:00:00 2001 From: "Eric N. Vander Weele" Date: Mon, 10 Apr 2023 10:43:44 -0400 Subject: [PATCH] completions/git: Allow switch to complete remote branches While it is true that `git switch ` errors to disallow a detached head without the `-d` option, it is valid to use any starting point (commit or reference) in conjunction with the `-c` option. Additionally, the starting point can occur before any option. This enables the following completions: * `git switch -c ` * `git switch -c ` * `git switch -d ` * `git switch -d` The trade-off is this does allow for `git switch ` to be completed with an error. Note that this logically reverts 7e3d3cc30f61d466f450a61ebee7c7fcd264967f. (cherry picked from commit fdd4bcf718693b6224404ae2215da7c44f0784ac) --- share/completions/git.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index a733ed073..900081d8d 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -1958,7 +1958,7 @@ complete -F -c git -n '__fish_git_using_command restore' -n '__fish_git_contains # switch options complete -f -c git -n __fish_git_needs_command -a switch -d 'Switch to a branch' complete -f -c git -n '__fish_git_using_command switch' -ka '(__fish_git_unique_remote_branches)' -d 'Unique Remote Branch' -complete -f -c git -n '__fish_git_using_command switch' -ka '(__fish_git_local_branches)' +complete -f -c git -n '__fish_git_using_command switch' -ka '(__fish_git_branches)' complete -f -c git -n '__fish_git_using_command switch' -s c -l create -d 'Create a new branch' complete -f -c git -n '__fish_git_using_command switch' -s C -l force-create -d 'Force create a new branch' complete -f -c git -n '__fish_git_using_command switch' -s d -l detach -d 'Switch to a commit for inspection and discardable experiment' -rka '(__fish_git_refs)'