summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJacob Keller <jacob.keller@gmail.com>2020-05-28 18:10:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-28 19:57:07 (GMT)
commit00e7bd2b0057a20d78193405af73b0acebdd86d2 (patch)
tree2c9236bc219f295f5224794d5938ca00224f2dce /t
parent6d76a5cc7fd19989b32a3b6d4a6132a7dd6aee4e (diff)
downloadgit-00e7bd2b0057a20d78193405af73b0acebdd86d2.zip
git-00e7bd2b0057a20d78193405af73b0acebdd86d2.tar.gz
git-00e7bd2b0057a20d78193405af73b0acebdd86d2.tar.bz2
completion: improve handling of --track in switch/checkout
Current completion for the --track option of git switch and git checkout is sub par. In addition to the DWIM logic of a bare branch name, --track has DWIM logic to convert specified remote/branch names into a local branch tracking that remote. For example $git switch --track origin/master This will create a local branch name master, that tracks the master branch of the origin remote. In fact, git switch --track on its own will not accept other forms of references. These must instead be specified manually via the -c/-C/-b/-B options. Introduce __git_remote_heads() and the "remote-heads" mode for __git_complete_refs. Use this when the --track option is provided while completing in _git_switch and _git_checkout. Just as in the --detach case, we never enable DWIM mode for --track, because it doesn't make sense. It should be noted that completion support is still a bit sub par when it comes to handling -c/-C and --orphan. This will be resolved in a future change. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t9902-completion.sh6
1 files changed, 2 insertions, 4 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 25d530a..2277326 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1404,16 +1404,14 @@ test_expect_success 'git checkout - with -d, complete only references' '
EOF
'
-#TODO: --track should only complete fully specified remote branches
-test_expect_failure 'git switch - with --track, complete only remote branches' '
+test_expect_success 'git switch - with --track, complete only remote branches' '
test_completion "git switch --track " <<-\EOF
other/branch-in-other Z
other/master-in-other Z
EOF
'
-#TODO: --track should only complete fully specified remote branches
-test_expect_failure 'git checkout - with --track, complete only remote branches' '
+test_expect_success 'git checkout - with --track, complete only remote branches' '
test_completion "git checkout --track " <<-\EOF
other/branch-in-other Z
other/master-in-other Z