completion: use "prev" variable instead of introducing "prevword"
In both _git_checkout and _git_switch a new "prevword" variable were introduced, however the "prev" variable already contains the last word. The "prevword" variable is replaced with "prev", and the case is moved to the beginning of the function, like it's done in many other places (e.g. _git_commit). Also the indentaion of the case is fixed. Signed-off-by: Ákos Uzonyi <uzonyi.akos@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
9bc233ae1c
commit
c09d1280f7
@ -1508,18 +1508,9 @@ _git_checkout ()
|
||||
{
|
||||
__git_has_doubledash && return
|
||||
|
||||
case "$cur" in
|
||||
--conflict=*)
|
||||
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
|
||||
;;
|
||||
--*)
|
||||
__gitcomp_builtin checkout
|
||||
;;
|
||||
*)
|
||||
local dwim_opt="$(__git_checkout_default_dwim_mode)"
|
||||
local prevword prevword="${words[cword-1]}"
|
||||
|
||||
case "$prevword" in
|
||||
case "$prev" in
|
||||
-b|-B|--orphan)
|
||||
# Complete local branches (and DWIM branch
|
||||
# remote branch names) for an option argument
|
||||
@ -1533,6 +1524,14 @@ _git_checkout ()
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
--conflict=*)
|
||||
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
|
||||
;;
|
||||
--*)
|
||||
__gitcomp_builtin checkout
|
||||
;;
|
||||
*)
|
||||
# At this point, we've already handled special completion for
|
||||
# the arguments to -b/-B, and --orphan. There are 3 main
|
||||
# things left we can possibly complete:
|
||||
@ -2392,18 +2391,9 @@ _git_status ()
|
||||
|
||||
_git_switch ()
|
||||
{
|
||||
case "$cur" in
|
||||
--conflict=*)
|
||||
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
|
||||
;;
|
||||
--*)
|
||||
__gitcomp_builtin switch
|
||||
;;
|
||||
*)
|
||||
local dwim_opt="$(__git_checkout_default_dwim_mode)"
|
||||
local prevword prevword="${words[cword-1]}"
|
||||
|
||||
case "$prevword" in
|
||||
case "$prev" in
|
||||
-c|-C|--orphan)
|
||||
# Complete local branches (and DWIM branch
|
||||
# remote branch names) for an option argument
|
||||
@ -2417,6 +2407,14 @@ _git_switch ()
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
--conflict=*)
|
||||
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
|
||||
;;
|
||||
--*)
|
||||
__gitcomp_builtin switch
|
||||
;;
|
||||
*)
|
||||
# Unlike in git checkout, git switch --orphan does not take
|
||||
# a start point. Thus we really have nothing to complete after
|
||||
# the branch name.
|
||||
|
Loading…
x
Reference in New Issue
Block a user