diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-01-30 14:17:09 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-01-30 14:17:09 -0800 |
| commit | fec1ff97c2b3c9c5db7e8f2df8d2c81cb94972fd (patch) | |
| tree | 1e07ad7a23ca8e40014330a092ff86e434b500b4 /t | |
| parent | c7372c9e2c11fa0adbfef2b9c5e5ba4ce19eb688 (diff) | |
| parent | 7d5ecd775de33878f00055e0024a003ab4edfbce (diff) | |
| download | git-fec1ff97c2b3c9c5db7e8f2df8d2c81cb94972fd.tar.gz | |
Merge branch 'sg/completion-worktree'
The command line completion (in contrib/) learned to complete
subcommands and arguments to "git worktree".
* sg/completion-worktree:
completion: list paths and refs for 'git worktree add'
completion: list existing working trees for 'git worktree' subcommands
completion: simplify completing 'git worktree' subcommands and options
completion: return the index of found word from __git_find_on_cmdline()
completion: clean up the __git_find_on_cmdline() helper function
t9902-completion: add tests for the __git_find_on_cmdline() helper
Diffstat (limited to 't')
| -rwxr-xr-x | t/t9902-completion.sh | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 93877ba9cd..5505e5aa24 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1363,6 +1363,63 @@ test_expect_success 'teardown after path completion tests' ' BS\\dir '$'separators\034in\035dir'' ' +test_expect_success '__git_find_on_cmdline - single match' ' + echo list >expect && + ( + words=(git command --opt list) && + cword=${#words[@]} && + __git_find_on_cmdline "add list remove" >actual + ) && + test_cmp expect actual +' + +test_expect_success '__git_find_on_cmdline - multiple matches' ' + echo remove >expect && + ( + words=(git command -o --opt remove list add) && + cword=${#words[@]} && + __git_find_on_cmdline "add list remove" >actual + ) && + test_cmp expect actual +' + +test_expect_success '__git_find_on_cmdline - no match' ' + ( + words=(git command --opt branch) && + cword=${#words[@]} && + __git_find_on_cmdline "add list remove" >actual + ) && + test_must_be_empty actual +' + +test_expect_success '__git_find_on_cmdline - single match with index' ' + echo "3 list" >expect && + ( + words=(git command --opt list) && + cword=${#words[@]} && + __git_find_on_cmdline --show-idx "add list remove" >actual + ) && + test_cmp expect actual +' + +test_expect_success '__git_find_on_cmdline - multiple matches with index' ' + echo "4 remove" >expect && + ( + words=(git command -o --opt remove list add) && + cword=${#words[@]} && + __git_find_on_cmdline --show-idx "add list remove" >actual + ) && + test_cmp expect actual +' + +test_expect_success '__git_find_on_cmdline - no match with index' ' + ( + words=(git command --opt branch) && + cword=${#words[@]} && + __git_find_on_cmdline --show-idx "add list remove" >actual + ) && + test_must_be_empty actual +' test_expect_success '__git_get_config_variables' ' cat >expect <<-EOF && |
