Skip to content

Commit f41c5a5

Browse files
committed
Merge branch 'js/complete-checkout-t'
The completion script (in contrib/) has been taught to treat the "-t" option to "git checkout" and "git switch" just like the "--track" option, to complete remote-tracking branches. * js/complete-checkout-t: completion(switch/checkout): treat --track and -t the same
2 parents 921a713 + 9f89283 commit f41c5a5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

contrib/completion/git-completion.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ _git_checkout ()
16071607

16081608
if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then
16091609
__git_complete_refs --mode="refs"
1610-
elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
1610+
elif [ -n "$(__git_find_on_cmdline "-t --track")" ]; then
16111611
__git_complete_refs --mode="remote-heads"
16121612
else
16131613
__git_complete_refs $dwim_opt --mode="refs"
@@ -2514,7 +2514,7 @@ _git_switch ()
25142514

25152515
if [ -n "$(__git_find_on_cmdline "-c -C -d --detach")" ]; then
25162516
__git_complete_refs --mode="refs"
2517-
elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
2517+
elif [ -n "$(__git_find_on_cmdline "-t --track")" ]; then
25182518
__git_complete_refs --mode="remote-heads"
25192519
else
25202520
__git_complete_refs $dwim_opt --mode="heads"

t/t9902-completion.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,14 +1622,22 @@ test_expect_success 'git checkout - with -d, complete only references' '
16221622
'
16231623

16241624
test_expect_success 'git switch - with --track, complete only remote branches' '
1625-
test_completion "git switch --track " <<-\EOF
1625+
test_completion "git switch --track " <<-\EOF &&
1626+
other/branch-in-other Z
1627+
other/main-in-other Z
1628+
EOF
1629+
test_completion "git switch -t " <<-\EOF
16261630
other/branch-in-other Z
16271631
other/main-in-other Z
16281632
EOF
16291633
'
16301634

16311635
test_expect_success 'git checkout - with --track, complete only remote branches' '
1632-
test_completion "git checkout --track " <<-\EOF
1636+
test_completion "git checkout --track " <<-\EOF &&
1637+
other/branch-in-other Z
1638+
other/main-in-other Z
1639+
EOF
1640+
test_completion "git checkout -t " <<-\EOF
16331641
other/branch-in-other Z
16341642
other/main-in-other Z
16351643
EOF

0 commit comments

Comments
 (0)