Skip to content

Commit 741f1f8

Browse files
committed
Merge branch 'au/complete-restore-s'
The command line completion (in contrib/) learned that "git restore -s <TAB>" is often followed by a refname. * au/complete-restore-s: completion: complete refs after 'git restore -s' completion: use "prev" variable instead of introducing "prevword"
2 parents 03b0198 + 0bc18da commit 741f1f8

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

contrib/completion/git-completion.bash

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,22 @@ _git_checkout ()
15081508
{
15091509
__git_has_doubledash && return
15101510

1511+
local dwim_opt="$(__git_checkout_default_dwim_mode)"
1512+
1513+
case "$prev" in
1514+
-b|-B|--orphan)
1515+
# Complete local branches (and DWIM branch
1516+
# remote branch names) for an option argument
1517+
# specifying a new branch name. This is for
1518+
# convenience, assuming new branches are
1519+
# possibly based on pre-existing branch names.
1520+
__git_complete_refs $dwim_opt --mode="heads"
1521+
return
1522+
;;
1523+
*)
1524+
;;
1525+
esac
1526+
15111527
case "$cur" in
15121528
--conflict=*)
15131529
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
@@ -1516,23 +1532,6 @@ _git_checkout ()
15161532
__gitcomp_builtin checkout
15171533
;;
15181534
*)
1519-
local dwim_opt="$(__git_checkout_default_dwim_mode)"
1520-
local prevword prevword="${words[cword-1]}"
1521-
1522-
case "$prevword" in
1523-
-b|-B|--orphan)
1524-
# Complete local branches (and DWIM branch
1525-
# remote branch names) for an option argument
1526-
# specifying a new branch name. This is for
1527-
# convenience, assuming new branches are
1528-
# possibly based on pre-existing branch names.
1529-
__git_complete_refs $dwim_opt --mode="heads"
1530-
return
1531-
;;
1532-
*)
1533-
;;
1534-
esac
1535-
15361535
# At this point, we've already handled special completion for
15371536
# the arguments to -b/-B, and --orphan. There are 3 main
15381537
# things left we can possibly complete:
@@ -2392,6 +2391,22 @@ _git_status ()
23922391

23932392
_git_switch ()
23942393
{
2394+
local dwim_opt="$(__git_checkout_default_dwim_mode)"
2395+
2396+
case "$prev" in
2397+
-c|-C|--orphan)
2398+
# Complete local branches (and DWIM branch
2399+
# remote branch names) for an option argument
2400+
# specifying a new branch name. This is for
2401+
# convenience, assuming new branches are
2402+
# possibly based on pre-existing branch names.
2403+
__git_complete_refs $dwim_opt --mode="heads"
2404+
return
2405+
;;
2406+
*)
2407+
;;
2408+
esac
2409+
23952410
case "$cur" in
23962411
--conflict=*)
23972412
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
@@ -2400,23 +2415,6 @@ _git_switch ()
24002415
__gitcomp_builtin switch
24012416
;;
24022417
*)
2403-
local dwim_opt="$(__git_checkout_default_dwim_mode)"
2404-
local prevword prevword="${words[cword-1]}"
2405-
2406-
case "$prevword" in
2407-
-c|-C|--orphan)
2408-
# Complete local branches (and DWIM branch
2409-
# remote branch names) for an option argument
2410-
# specifying a new branch name. This is for
2411-
# convenience, assuming new branches are
2412-
# possibly based on pre-existing branch names.
2413-
__git_complete_refs $dwim_opt --mode="heads"
2414-
return
2415-
;;
2416-
*)
2417-
;;
2418-
esac
2419-
24202418
# Unlike in git checkout, git switch --orphan does not take
24212419
# a start point. Thus we really have nothing to complete after
24222420
# the branch name.
@@ -2843,6 +2841,13 @@ _git_reset ()
28432841

28442842
_git_restore ()
28452843
{
2844+
case "$prev" in
2845+
-s)
2846+
__git_complete_refs
2847+
return
2848+
;;
2849+
esac
2850+
28462851
case "$cur" in
28472852
--conflict=*)
28482853
__gitcomp "diff3 merge" "" "${cur##--conflict=}"

0 commit comments

Comments
 (0)