diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-11-02 16:53:18 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-11-02 16:53:18 +0900 |
commit | d12df942ba017c1301a51083b82431e9b3699a11 (patch) | |
tree | 17d29cf643440576ec04558b800ffebe41ac0377 | |
parent | 17ab51ee8ffcecc62813fe6c744cabb924f3fc9f (diff) | |
parent | 9f892830d6965d68bfa937cebcfbed9c9e552700 (diff) | |
download | git-d12df942ba017c1301a51083b82431e9b3699a11.tar.gz |
Merge branch 'js/complete-checkout-t' into maint-2.42
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
-rw-r--r-- | contrib/completion/git-completion.bash | 4 | ||||
-rwxr-xr-x | t/t9902-completion.sh | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 133ec92bfa..745dc901fb 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1607,7 +1607,7 @@ _git_checkout () if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then __git_complete_refs --mode="refs" - elif [ -n "$(__git_find_on_cmdline "--track")" ]; then + elif [ -n "$(__git_find_on_cmdline "-t --track")" ]; then __git_complete_refs --mode="remote-heads" else __git_complete_refs $dwim_opt --mode="refs" @@ -2514,7 +2514,7 @@ _git_switch () if [ -n "$(__git_find_on_cmdline "-c -C -d --detach")" ]; then __git_complete_refs --mode="refs" - elif [ -n "$(__git_find_on_cmdline "--track")" ]; then + elif [ -n "$(__git_find_on_cmdline "-t --track")" ]; then __git_complete_refs --mode="remote-heads" else __git_complete_refs $dwim_opt --mode="heads" diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 8835e16e81..47e20fb8b1 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1622,14 +1622,22 @@ test_expect_success 'git checkout - with -d, complete only references' ' ' test_expect_success 'git switch - with --track, complete only remote branches' ' - test_completion "git switch --track " <<-\EOF + test_completion "git switch --track " <<-\EOF && + other/branch-in-other Z + other/main-in-other Z + EOF + test_completion "git switch -t " <<-\EOF other/branch-in-other Z other/main-in-other Z EOF ' test_expect_success 'git checkout - with --track, complete only remote branches' ' - test_completion "git checkout --track " <<-\EOF + test_completion "git checkout --track " <<-\EOF && + other/branch-in-other Z + other/main-in-other Z + EOF + test_completion "git checkout -t " <<-\EOF other/branch-in-other Z other/main-in-other Z EOF |