1508
local prevword prevword="${words[cword-1]}"
1509
1510
case "$prevword" in
1511
- -b|-B)
1511
+ -b|-B|--orphan)
1512
# Complete local branches (and DWIM branch
1513
# remote branch names) for an option argument
1514
# specifying a new branch name. This is for
1522
esac
1523
1524
# At this point, we've already handled special completion for
1525
- # the arguments to -b/-B. There are 3 main things left we can
1526
- # possibly complete:
1527
- # 1) a start-point for -b/-B or -d/--detach
1525
+ # the arguments to -b/-B, and --orphan. There are 3 main
1526
+ # things left we can possibly complete:
1527
+ # 1) a start-point for -b/-B, -d/--detach, or --orphan
1528
# 2) a remote head, for --track
1529
# 3) an arbitrary reference, possibly including DWIM names
1530
#
1531
1532
- if [ -n "$(__git_find_on_cmdline "-b -B -d --detach")" ]; then
1532
+ if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then
1533
__git_complete_refs --mode="refs"
1534
elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
1535
__git_complete_refs --mode="remote-heads"
2387
local prevword prevword="${words[cword-1]}"
2388
2389
case "$prevword" in
2390
- -c|-C)
2390
+ -c|-C|--orphan)
2391
# Complete local branches (and DWIM branch
2392
# remote branch names) for an option argument
2393
# specifying a new branch name. This is for
2400
;;
2401
esac
2402
2403
+ # Unlike in git checkout, git switch --orphan does not take
2404
+ # a start point. Thus we really have nothing to complete after
2405
+ # the branch name.
2406
+ if [ -n "$(__git_find_on_cmdline "--orphan")" ]; then
2407
+ return
2408
+ fi
2409
+
2410
# At this point, we've already handled special completion for
2404
- # -c/-C. There are 3 main things left to
2411
+ # -c/-C, and --orphan. There are 3 main things left to
2412
# complete:
2413
# 1) a start-point for -c/-C or -d/--detach
2414
# 2) a remote head, for --track