completion: add tests showing subpar -c/-C startpoint completion

When using the branch creation argument for git switch or git checkout,
-c/-C or -b/-B, the commands operate in a different mode: `git switch -c
<branch> <some-reference>` means to create a branch named <branch> at
the commit referred to by <some-reference>.

When completing the start-point, we ought to always complete all valid
references.

Add tests for the completion of the start-point to -c/-C and -b/-B.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jacob Keller 2020-05-28 11:10:37 -07:00 committed by Junio C Hamano
parent c55b99c3d3
commit b07d77a2ba

View File

@ -1448,6 +1448,146 @@ test_expect_success 'git checkout - with --no-track, complete only local referen
EOF
'
#TODO: completing the start point of -c/-C should not include DWIM references
test_expect_failure 'git switch - with -c, complete all references' '
test_completion "git switch -c new-branch " <<-\EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
#TODO: completing the start point of -c/-C should not include DWIM references
test_expect_failure 'git switch - with -C, complete all references' '
test_completion "git switch -C new-branch " <<-\EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
#TODO: completing the start point of -c/-C should include all references, not just local branches
test_expect_failure 'git switch - with -c and --track, complete all references' '
test_completion "git switch -c new-branch --track " <<-EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
#TODO: completing the start point of -c/-C should include all references, not just local branches
test_expect_failure 'git switch - with -C and --track, complete all references' '
test_completion "git switch -C new-branch --track " <<-EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
#TODO: completing the start point of -c/-C should include all references, not just local branches
test_expect_failure 'git switch - with -c and --no-track, complete all references' '
test_completion "git switch -c new-branch --no-track " <<-\EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
#TODO: completing the start point of -c/-C should include all references, not just local branches
test_expect_failure 'git switch - with -C and --no-track, complete all references' '
test_completion "git switch -C new-branch --no-track " <<-\EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
#TODO: completing the start point of -b/-B should not include DWIM references
test_expect_failure 'git checkout - with -b, complete all references' '
test_completion "git checkout -b new-branch " <<-\EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
#TODO: completing the start point of -b/-B should not include DWIM references
test_expect_failure 'git checkout - with -B, complete all references' '
test_completion "git checkout -B new-branch " <<-\EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
test_expect_success 'git checkout - with -b and --track, complete all references' '
test_completion "git checkout -b new-branch --track " <<-EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
test_expect_success 'git checkout - with -B and --track, complete all references' '
test_completion "git checkout -B new-branch --track " <<-EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
test_expect_success 'git checkout - with -b and --no-track, complete all references' '
test_completion "git checkout -b new-branch --no-track " <<-\EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
test_expect_success 'git checkout - with -B and --no-track, complete all references' '
test_completion "git checkout -B new-branch --no-track " <<-\EOF
HEAD Z
master Z
matching-branch Z
matching-tag Z
other/branch-in-other Z
other/master-in-other Z
EOF
'
test_expect_success 'teardown after ref completion' '
git branch -d matching-branch &&
git tag -d matching-tag &&